三个表的SQL JOIN

时间:2014-11-04 10:41:54

标签: mysql sql oracle

我有三张桌子

tbl_Service

1)sId
2)Name

tbl_quatItem

1)iId
2)quat_ID
3)ser_Id

tbl_quat

1)qId
2)date
3)Name

我已尝试过以下声明

select s.*, q.* 
from tbl_service s, tbl_quatItem q 
where q.quatID = 1001 
and s.sId not in q.qutID 

现在,我想要从tbl_Servicetbl_quatItem

中的quat_Id = qID获取数据

1 个答案:

答案 0 :(得分:0)

select * from tbl_Service where sId not in  (select ser_Id from tbl_quat_ID where quat_Id != <qID>)

我希望从应用程序端传递qID ..你只需要附加字符串以传递适当的值