Home > Enterprise >  How can i get the same value from same table?
How can i get the same value from same table?

Time:11-02

Hey guys I have a long table in my Database and i want select all records that have the same id and parent_id.

id name parent_id
2 lorem 2

Thanks in advance.

CodePudding user response:

you simply need to put an = sign for the column that you want to have the same values. Passing this condition to the where clause will filter the rows to show only the ones where the two columns are equal.

select * from <your_table_name> where id = parent_id
  • <your_table_name> = pass your table name

CodePudding user response:

SELECT ID,
       PARENT_ID 
FROM TABLENAME 
WHERE ID=PARENT_ID

CodePudding user response:

I think you can use this structure:

SELECT [column list] FROM [tablename] WHERE id=parent_id
  • Related