SELECT
*
FROM
hcc_server.t_project tp
WHERE
is_enable = 1
AND is_del = 0
-- AND id IN (10161, 10163, 10319)
AND tp.id NOT IN (
SELECT
sc.company_code
FROM
hcc_admin.sys_company sc
);
-- 先查询子查询的表, 然后将内表和外表做一个笛卡尔积, 然后按条件进行筛选, 所以相对内标比较小的时候,
-- not in 的速度较快
SELECT
*
FROM
hcc_server.t_project
WHERE
is_enable = 1
AND is_del = 0
-- AND id IN (10161, 10163, 10319)
AND NOT EXISTS (
SELECT
company_code
FROM
hcc_admin.sys_company
WHERE
company_code = hcc_server.t_project.id
)
-- 遍历查询, 每条记录带到子查询中判断
11-03
11-03