jwwceo Posted August 28, 2006 Share Posted August 28, 2006 I have a databse with three tables. shirts, colors, and shirtcolors. Shirtcolors has 2 fields for the primary keys for both shirts and colors, linking up shirts and what colors thet come in...my customers are going to be selecting a color from a pulldown and I want to have a search results page display all the shirts that have that color...I have never pulled data from 2 tables before...what's the best way to do this???? Link to comment https://forums.phpfreaks.com/topic/18949-join-tables-queries-are-confusing/ Share on other sites More sharing options...
hitman6003 Posted August 28, 2006 Share Posted August 28, 2006 [code][code]Use a join...http://dev.mysql.com/doc/refman/5.0/en/join.html[/code]SELECT * FROM shirtcolors LEFT JOIN colors ON shirtcolors.color_id = colors.color_id LEFT JOIN shirts ON shirtcolors.shirt_id = shirts.shirt_idWHERE color = 'Blue';[/code] Link to comment https://forums.phpfreaks.com/topic/18949-join-tables-queries-are-confusing/#findComment-81841 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.