#INNER JOIN - this gives common elements from user & product
SELECT user.name, product.name
FROM user INNER JOIN product ON user.product_id = product.id
#LEFT JOIN - this gives all user & matching product
SELECT user.name, product.name
FROM user LEFT JOIN product ON user.product_id = product.id
#RIGHT JOIN - this gives all product with user
SELECT user.name, product.name
FROM user RIGHT JOIN product ON user.product_id = product.id
SELECT user.name, product.name
FROM user INNER JOIN product ON user.product_id = product.id
#LEFT JOIN - this gives all user & matching product
SELECT user.name, product.name
FROM user LEFT JOIN product ON user.product_id = product.id
#RIGHT JOIN - this gives all product with user
SELECT user.name, product.name
FROM user RIGHT JOIN product ON user.product_id = product.id
No comments:
Post a Comment