【发布时间】:2020-07-25 09:44:32
【问题描述】:
SELECT organizations_organization.code as organization,
core_user.email as Created_By,
assinees.email as Assigned_To,
from tickets_ticket
JOIN organizations_organization on tickets_ticket.organization_id = organizations_organization.id
JOIN core_user on tickets_ticket.created_by_id = core_user.id
Left JOIN core_user as assinees on assinees.id = tickets_ticket.currently_assigned_to_id
在上述查询中,如果tickets_ticket.currently_assigned_to_id 为空,则不返回tickets_ticket 中的那一行
> Records In tickets_ticket = 109
> Returned Records = 4 (out of 109 4 row has value for currently_assigned_to_id rest 105 are null )
> Expected Records = 109 (with nulll set for Assigned_To)
注意我正在尝试在同一个表上实现多个连接
【问题讨论】:
-
只是为了让事情更清楚,
INNER关键字是可选的。 IE。INNER JOIN与JOIN相同。
标签: sql postgresql join