我的查詢從MySQL DB中選擇任務。每個任務都有一個組ID,如果組等於0,則它是一個我只希望返回的私人任務,如果任務來自運行此查詢的用戶。希望是有道理的:-)MySQL:如果在哪裏?
SELECT t.id, t.title, t.created_by, u.username
FROM (p_tasks AS t)
LEFT JOIN p_groups AS g ON t.group_id = g.id
JOIN p_users AS u ON t.assigned_to_user_id = u.id
WHERE
(
t.assigned_to_user_id = $user_id OR
t.owner_user_id = $user_id
)
AND
(
g.priority >= '10' OR
t.group_id = 0
)
AND
(
t.status != "approved" AND
t.status != "closed"
)
ORDER BY c.name
我只能爲那些創建任務的人返回group_id = 0的任務嗎?