Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 使用like查询跨两个表获得所需的输出_Mysql_Hibernate - Fatal编程技术网

Mysql 使用like查询跨两个表获得所需的输出

Mysql 使用like查询跨两个表获得所需的输出,mysql,hibernate,Mysql,Hibernate,大家好,我正在尝试实现下面的查询,根据给定的条件从两个表返回结果。如何进行正确的查询以获得预期的输出 SELECT * FROM bw_tempclientdetails where companyname like '%fff%' not in (SELECT * FROM bw_clientallocation where companyname like '%fff%'); 使用使用 select t1.* from ( SELECT * FROM bw_tempclient

大家好,我正在尝试实现下面的查询,根据给定的条件从两个表返回结果。如何进行正确的查询以获得预期的输出

SELECT * FROM  bw_tempclientdetails  
where companyname like '%fff%'  
not in (SELECT * FROM bw_clientallocation where companyname like '%fff%');
使用使用
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
SELECT * FROM  bw_tempclientdetails  
where companyname like '%fff%' and companyname   
not in (SELECT companyname FROM bw_clientallocation where companyname like '%fff%');
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%');