Thanks, for your help, I posted a simplified version of my problem but I really didn't understand how to apply the left join in the big one that is this:
SELECT d.type,
d.item ,
if(d.type='I', a.name, b.name) as name,
if(d.type='I', c.price,0) as price,
if(d.type='I',if(d.taxes='yes',
(c.priceWithTax*d.weight), (c.price*d.weight)),0) as totalprice
FROM d
inner join a on d.item=a.id
inner join c on d.item=c.item
where c.sede =1
The problem is that when d.type='I' I need the items from table a, but if d.type='S' I need the items from table B, the prices are on table c.
Thank you very much.