2011-08-08 37 views

回答

1

使用join < --follow鏈接

SELECT * 
    FROM bw_tempclientdetails bw_temp 
    LEFT JOIN bw_clientallocation bw_client 
    ON bw_temp.companyname = bw_client.companyname -- this is just an identifier or link between the tables 
WHERE bw_client.company LIKE '%fff%' 
    AND (bw_temp.companyname LIKE '%fff%' AND bw_client.company LIKE '%fff%'); 

希望它能幫助。祝你好運。

+0

非常感謝你這個解決方案幫助 –

+0

不客氣..祝你的工作.. :) – sailhenz

0
select t1.* from (
SELECT * FROM bw_tempclientdetails 
where companyname like '%fff%') as t1 
left join (SELECT * FROM bw_clientallocation where companyname like '%fff%') as t2 
on t1.companyname = t2.companyname 
where t2.companyname is null 
+0

感謝兄弟爲您的解決方案 –

2
SELECT * FROM bw_tempclientdetails 
where companyname like '%fff%' and companyname 
not in (SELECT companyname FROM bw_clientallocation where companyname like '%fff%'); 
+0

這種解決方案看起來非常簡單,感謝花花公子 –

+0

我很高興如果我幫助。祝你好運;) –