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
for your case 2 where you want the rows that matches the id = parent_id but they are not in the same row:
you need a self-join
SELECT
*
FROM
<table_name> as t1
INNER JOIN <table_name> as t2
on t1.id = t2.parent_id
if in different tables:
SELECT * FROM table1 WHERE parent_id in (SELECT id FROM table2)
3
Answers
I think you can use this structure:
you simply need to put an
=
sign for the column that you want to have the same values. Passing this condition to thewhere
clause will filter the rows to show only the ones where the two columns are equal.for your case 2 where you want the rows that matches the id = parent_id but they are not in the same row:
if in different tables: