How to get names form 3 different tables
Finally as I did not see any hope I inserted a column "prodname" and with this sql I got the result. But any help will be welcome this add of prodname makes my TB_A table a little bulky.

Here is the SQL

SELECT sd.prodname, sd.date, 
SUM(IF((sd.status=0 AND (sd.prodid=pb.id OR sd.prod.id=pm.id OR sd.prodid =pg.id)), sd.qty,0)) AS tot,
SUM(IF((sd.status &gt;0 AND (sd.prodid=pb.id OR sd.prodid=pm.id OR sd.prodid=pg.id)), sd.qty, 0)) AS rq
FROM TB_A AS sd
LEFT JOIN TB_B AS pb ON pb.id=sd.prodid
LEFT JOIN TB_C AS pm ON pm.id=sd.prodid
LEFT JOIN TB_D AS pg ON pg.id=sd.prodid
WHERE sd.stat&gt;1
GROUP BY pm.id,pm.id,pg.id,sd.prodname  
ORDER BY sd.date DESC


PS:In my display of my program I don't display rq I display tot-rq within a program. Any suggestion for getting that in this query is welcome.