im new to SQL and want to know how to replace the below code with SQL joins.
I want to list all information based on p_id ='123'.
select p.p_name,c.c_name,s.s_name,s.s_contact,b.b_name,b.b_contact
from product p, category c, seller s, buyer b
where p.p_id="123" and c.p_id="123" and s.p_id="123" and b.p_id="123";
Tables used
Product Table
p_id
p_name
Category Table
p_id
c_id
c_name
Seller Table
p_id
s_id
s_name
s_contact
Buyer Table
p_id
b_id
b_name
b_contact
Thanks
This is the query using join:
Try joining all the table with your criteria as below: