2014-11-04 79 views
-4

我有三個表SQL JOIN三個表

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_Service獲取數據,是不是在tbl_quatItemquat_Id = qID

+1

好運氣呢。如果您遇到困難並請告訴我們在哪裏,請回來。 – 2014-11-04 10:44:32

+0

我想加入,但它不工作 – Snehal 2014-11-04 10:44:50

+2

你能告訴我們你已經通過編輯原來的問題做了什麼。另外,這些表如何鏈接? – franglais 2014-11-04 10:45:07

回答

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

我希望QID從應用端傳送..您只需將字符串傳遞正確的值有

+0

意味着查詢字符串會像 查詢字符串= 「SELECT * FROM tbl_Service其中SID不是(從tbl_quat_ID其中quat_Id =選擇ser_Id!」 + QID + 「)」; – Aun 2014-11-04 10:52:50

+0

歡迎..但請標記答案爲正確的:-) – Aun 2014-11-04 10:59:32