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???? Quote Link to comment 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] 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.