jjdave Posted September 1, 2006 Share Posted September 1, 2006 Hi All, any help will be appriciated. Thanks.I am trying to JOIN 3 Tables (X & Y & Z) with 1 Column (partlist_id) and my query does not work. I can not print the results. [code=php:0]$query="SELECT x.id, x.assy_part, y.part_no, y.part_desc, z.roll_id, z.roll_image FROM `$table_name` as x INNER JOIN `$vpt_table_partlist` as y ON y.partlist_id = x.partlist_id INNER JOIN `$vpt_table_rollover` as z ON z.partlist_id = x.partlist_id"; $result=mysql_query($query); $num=mysql_numrows($result); echo "<TD><br>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $part_no=mysql_result($result,$i,"part_no"); echo "$id : $part_no"; $i++; } echo "</TD></TR>";[/code]If I remove Table Z and only JOIN Table X & Y, with following code, then it works fine.[code=php:0]$query="SELECT x.id, x.assy_part, y.part_no, y.part_desc FROM `$table_name` as x INNER JOIN `$vpt_table_partlist` as y ON y.partlist_id = x.partlist_id"; $result=mysql_query($query); $num=mysql_numrows($result); echo "<TD><br>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $part_no=mysql_result($result,$i,"part_no"); echo "$id : $part_no"; $i++; } echo "</TD></TR>";[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted September 1, 2006 Share Posted September 1, 2006 Sounds like there are no records in z where z.partlist_id = x.partlist_id Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.