从多个列匹配多个行的同一个表中检索数据

时间:2022-09-16 14:31:00

I have a table with data where in a situation one rows' id becomes another rows reference id. The table is as below.

我有一个数据表,在某种情况下,一行的id成为另一行的引用ID。表格如下。

从多个列匹配多个行的同一个表中检索数据

I tried to retrieve data as below,

我试图检索如下数据,

select * from table1 t where t.id = t.reference_id

but it returns empty table.

但它返回空表。

1 个解决方案

#1


3  

Try a self join like :

尝试自我加入,如:

select * from table1 t1
inner join table1 t2 on t1.id = t2.reference_id

#1


3  

Try a self join like :

尝试自我加入,如:

select * from table1 t1
inner join table1 t2 on t1.id = t2.reference_id