PDA

View Full Version : Problem in joining three tables



newphpbees
27 Feb 2012, 03:47 AM
Hi..

I encountered problem in my query to display data.
here is my separate query then i mix up:



SELECT kc.PCODE, kc.count_wip_chemical_weighing, kc.count_wip_compounding, kc.count_wip_extrusion, kc.count_wip_forming, kc.count_wip_deflashing, kc.kanban, kc.virtual, p.max_lot, p.min_lot FROM kanban_checker kc JOIN plan p ON kc.PCODE = p.PCODE ORDER BY p.PCODE;




SELECT kd.LOT_CODE, kd.wip_chemicalweighing, kd.wip_compounding, kd.wip_extrusion, kd.wip_forming, kd.wip_deflashing
FROM kanban_data kd JOIN plan p ON kd.PCODE = p.PCODE ORDER BY p.PCODE;

mix query


SELECT p.PCODE, kd.LOT_CODE, kd.wip_chemicalweighing, kd.wip_compounding, kd.wip_extrusion, kd.wip_forming, kd.wip_deflashing, kc.count_wip_chemical_weighing, kc.count_wip_compounding, kc.count_wip_extrusion, kc.count_wip_forming, kc.count_wip_deflashing, kc.kanban, kc.virtual, p.max_lot, p.min_lot FROM kanban_data kd JOIN kanban_checker kc ON kd.PCODE = kc.PCODE JOIN plan p ON kc.PCODE = p.PCODE ORDER BY p.PCODE;


I want to display PCODE once. like one P35, one P35M .I want it to display with the kc.count_wip_chemical_weighing, kc.count_wip_compounding, kc.count_wip_extrusion, kc.count_wip_forming, kc.count_wip_deflashing, kc.kanban, kc.virtual, p.max_lot, p.min_lot,...No PCODE and max_lot, virtual, min_lot, kanban in this fields:
kd.LOT_CODE, kd.wip_chemicalweighing, kd.wip_compounding, kd.wip_extrusion, kd.wip_forming, kd.wip_deflashing

I attach the sample format I need to display which is the excel type and the html type the result from query.

Thank you

jassmee
27 Apr 2012, 07:27 AM
you are not used the write syntax in join in mysql.. and when you are using the join then relation in table is very important. join in mysql has four types: -
1.inner join
2.left join
3.right join
4.outer join