左连接多个表

时间:2022-07-21 01:58:41

essentially I want to left join 3 tables I have joined 2 tables below

实际上,我想要离开join 3个表,我在下面加入了2个表

SELECT  * 
FROM    Shop_id i
        LEFT JOIN Shopper s 
           ON i.shopper_id = s.uid
WHERE   i.shopper_comp > 0 AND 
        i.editor_comp = 0
ORDER BY i.sid

I have already successfully joined Shop_id i and Shopper s I want to add Clients c to the mix I thought-

我已经成功地加入了Shop_id I和购物者s

SELECT  * 
FROM    Shop_id i
        LEFT JOIN Shopper s, Clients c 
           ON i.shopper_id = s.uid AND i.cid = c.CID
WHERE   i.shopper_comp > 0 AND 
        i.editor_comp = 0
ORDER BY i.sid

I was wrong - Help please

我错了,请帮帮我

2 个解决方案

#1


5  

you need to explicitly specify the keyword LEFT JOIN for the table clients.

您需要显式地指定表客户端的关键字LEFT JOIN。

SELECT * 
FROM   Shop_id i
       LEFT JOIN Shopper s
          ON i.shopper_id = s.uid 
       LEFT JOIN Clients c 
          ON i.cid = c.CID
WHERE  i.shopper_comp > 0 AND 
       i.editor_comp = 0
ORDER BY i.sid

#2


1  

can you try like this?

你能试试这个吗?

SELECT * FROM Shop_id i
LEFT JOIN Shopper s ON i.shopper_id = s.uid
LEFT JOIN Clients c ON  i.cid = c.CID
WHERE i.shopper_comp >0 AND i.editor_comp =0
ORDER BY i.sid

#1


5  

you need to explicitly specify the keyword LEFT JOIN for the table clients.

您需要显式地指定表客户端的关键字LEFT JOIN。

SELECT * 
FROM   Shop_id i
       LEFT JOIN Shopper s
          ON i.shopper_id = s.uid 
       LEFT JOIN Clients c 
          ON i.cid = c.CID
WHERE  i.shopper_comp > 0 AND 
       i.editor_comp = 0
ORDER BY i.sid

#2


1  

can you try like this?

你能试试这个吗?

SELECT * FROM Shop_id i
LEFT JOIN Shopper s ON i.shopper_id = s.uid
LEFT JOIN Clients c ON  i.cid = c.CID
WHERE i.shopper_comp >0 AND i.editor_comp =0
ORDER BY i.sid