您好我有以下实体:
表格USER
:
id_user
Name
Username
role
表格TASK
:
id_task
task_Name
tipe
TABLE COMPLETED_TASK
:
id_task
id_user
表格ASSIGNED_TASK
:
id_task
id_user
有没有办法获得完整的任务列表“已完成并已分配”以及相应的用户?
我尝试了以下查询,但这并不完全正常,因为它无法返回所有TASK.id_task
SELECT * FROM TASK
LEFT OUTER JOIN COMPLETED_TASK ON TASK.id_task=COMPLETED_TASK.id_task
LEFT OUTER JOIN ASSIGNED_TASK ON TASK.id_task=ASSIGNED_TASK.id_task
INNER JOIN USER ON USER.id_user=ASSIGNED_TASK.id_user
OR USER.id_user=COMPLETED_TASK.id_user
答案 0 :(得分:0)
the real problem, is that sql join or more exactly left join,
return all the left table rows,
but return null value for the fieldset, that not have match in ON clause.
so i must fill a table whit all task,whit this head
<thead><th>id_task</th><th>Nametask</th><th>Assigned to</th>th>Tipology</th>
and i need for all task the fiedset id_task for edit and delete task.
so seems evry type of join dont give this result whats that the impossiblequery