大家好我正在尝试根据给定的条件实现以下查询以从两个表返回结果。如何放置正确的查询以达到预期的输出?
SELECT * FROM bw_tempclientdetails
where companyname like '%fff%'
not in (SELECT * FROM bw_clientallocation where companyname like '%fff%');
最佳答案
使用join
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%');
希望能帮助到你。祝好运。
关于mysql - 使用类似查询在两个表之间获取所需的输出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6980403/