我有3个表格,例如table1
,table2
和table3
以及
table1
t1_id, t1_name, t1_bookid
表2
t2_id, t2_name, t2_t1_id, t2_bookid
table3
t3_id, t3_name, t3_detail
如果t3_id
其他t2_bookid==t3_id
t1_bookid==t3_id
答案 0 :(得分:0)
尝试使用以下查询。
Select t3.id
From table3 t3
Where exists (Select 1
From table1 t1 where t1.bookId=t3.id)
Or exists (Select 1
From table2 t2 where t2.bookId=t3.id)