我有一个 In 子句,里面有查询。我想在那个 IN 中添加“NULL”。我该如何添加。
这是我的查询
WHERE `e`.`lead_id` IN (
select lds.lead_id
from mortgage_lead_leads lds
where lds.loan_officer_id=60
)
这给出了 10 条记录。我想在该 In 子句中添加另一条记录。谁能帮我吗。
您无需将其添加到 IN 列表中:
WHERE (`e`.`lead_id` IN (select lds.lead_id from mortgage_lead_leads lds
where lds.loan_officer_id=60)
OR `e`.`lead_id` is null)
请注意括号 - 如果您要添加另一个“AND 条件”语句可能很重要......
您可以使用带有 select null from dual 的 unio
WHERE `e`.`lead_id` IN
(select lds.lead_id from mortgage_lead_leads lds
where lds.loan_officer_id=60
union
select null from dual )
or 一个 or 子句
WHERE `e`.`lead_id` IN
(select lds.lead_id from mortgage_lead_leads lds
where lds.loan_officer_id=60 ) or `e`.`lead_id` is null