#sql #postgresql
#sql #postgresql
Вопрос:
У меня есть один запрос, написанный на postgresql
select components.*
from sg_paycomponents components
left outer join tblextempinfo info
on info.c_company=components.company
where components.type ='RECURRING-AMOUNTS'
and components.cid not in (
select components
from sg_recurringamounts
where employee =400
)
and info.employee=400;
этот запрос выдает мне всю запись, но я хочу, чтобы в таблице sg_paycomponents я также должен получить эту запись, где type = ‘RECURRENT-AMOUNTS’ и company равно нулю, мой запрос не выдает мне, если company равна нулю, может ли кто-нибудь помочь, пожалуйста
Ответ №1:
Изменить:
and info.employee=400
Для:
and (info.employee=400 OR info.employee IS NULL)