表:
users: id INT
items: id INT
setid INT
sets: id INT
relationships: userid INT
itemid INT
relationship ENUM( owner , participant )
鉴于<条码>使用<>条码/代码>和<条码>setid,我们需要编制一份清单,列出所设计的所有物项,如果存在关系,则用户与每个项目的关系。 一、结果
setid itemid relationship
---------------------------------
1 1 NULL
1 2 owner
....
The following don t work, as the second where
条款删除了<代码>relationship的行文。 页: 1
select
sets.id as setid,
items.id as itemid,
relatonships.relationship as relationship
from sets
inner join items on sets.id = items.setid
left join relationships on relationships.itemid = items.id
where
sets.id = 5
and relationships.userid = 27
但是,第二个<代码>,条款删除了该项目与特定用户之间不存在现有关系的行文。 如何以单一方式做到这一点?