medj Posted June 6, 2008 Share Posted June 6, 2008 Hopefully someone can help me out with this. I have a database with 2 tables. I simply would like to perform a query that will display the rows where the "Part Number" of the first table matches the "Manufacturing Number" of the second one. This works out fine for me since I'm using this code: $function_match = mysql_query( "SELECT * FROM components, bom_dimwheel_white WHERE `components`.`part_num` = `bom_dimwheel_white`.`manufacturer_num`" ) or die("SELECT Error: ".mysql_error()); I have about 20 column/fields in "components" and 10 in "bom_dimwheel_white". When I display my results of the query, I am getting all 30 fields being displayed when all I want is to show the results of the components table. What I mean is that the display should only have the 20 field columns from the 'components' table. Can anyone help me out? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted June 7, 2008 Share Posted June 7, 2008 When using an JOIN you'll need to use GROUP BY to prevent duplicate results. So use: $function_match = mysql_query( "SELECT * FROM components, bom_dimwheel_white WHERE `components`.`part_num` = `bom_dimwheel_white`.`manufacturer_num` GROUP BY `components`.`part_num`" ) or die("SELECT Error: ".mysql_error()); 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.