Tuesday, 3 September 2013

sql left join select all records from left table even if no records in rigth table

sql left join select all records from left table even if no records in
rigth table

i am trying to run following query :
select ifnull(sum(item_actual_qty),0) as aa,b.item_name,a.item_Code from
transaction_inventory AS a left join inventory_master as b
on b.item_code = a.item_code and b.company_code = a.company_code
WHERE a.item_Code = 2222
and a.company_code = '52889497-5b6b-403d-8f83-224e3c7759b4'
AND a.trans_type_name NOT IN ('Sales Order','Purchase Order')
AND a.trans_date < '2010-04-01' ;
how do i select records from inventory_master even if there are not
records in transaction_inventory ? currently its giving null value for
b.item_name which should give the actual item name from master table.

No comments:

Post a Comment