To join multiple tables, we use JOIN keyword.
Example :
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
INNER JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName
Say if you want to join 3 tables, then the query will be :
SELECT c.cat_id, c.cat_name, s.subcat_name, p.prd_name, prd_price
FROM Category c
INNER JOIN Product p
ON p.prd_cid=c.cat_id
INNER JOIN Subcategory s
ON p.prd_sid=s.subcat_id
No comments:
Post a Comment