mysql - Joining two tables for the result? -
i have 2 tables in database person
, order
tables.
person table:
person_id | name
order table:
order_id | order_no | person_id
i need display orders + name of corresponding person if exists, if not order details.
so far got query:
select order_id, order_no, order.person_id, name person, order person.person_id = order.person_id , person.first_name not null;
which gives me orders if name available whereas need display orders despite fact if name available or not.
any suggestions?
yes, can use left join
that:
select o.order_id, o.order_no, o.person_id, p.name `order` o left join person p on p.person_id = o.person_id , p.first_name not null
with left join
if name
null
still give orders.
Comments
Post a Comment