inner join和left join

Query all goods (product), containing all of his comments (comment), contains the user under review

need to use

SELECT  * FROM product p
LEFT JOIN COMMENT c ON p.pid=c.product_id
LEFT JOIN USER u ON c.other_user_id=u.id

 

and

SELECT  * FROM product p
INNER JOIN COMMENT c ON p.pid=c.product_id
INNER JOIN USER u WHERE c.other_user_id=u.id

Some queries can only be achieved based on the right

 

Guess you like

Origin www.cnblogs.com/shuaiqin/p/10966317.html