MySQL query from multiple tables

From: Date: Sat, 29 Jun 2002 02:56:47 +0000
Subject: MySQL query from multiple tables
Groups: php.db 
Request: Send a blank email to php-db+get-20195@lists.php.net to get a copy of this message
Hi All, I have a strange query which I need to build - I have looked at the JOIN and aliasing functions of mySQL but not sure if I can achieve want I want to do. I have two tables (product_head, and product_features) (in addition to a number of other tables) which form the list of products I have available, and the features available with each product. I want to be able to retrieve from product_head the rows which are for a specific product category (ie: 1).. this bit is easy. SELECT * from product_head where prod_cat_ID = 1; This query could return 1 or more rows - works great. but I also want to retrieve records from the product_features table. information stored in this table is: prod_ID feat_ID feat_value so for each product ID, there could be any number of features. I need to retrieve only certain feat_value records, for specific products, where the feat_ID equals certain values . can I build a single query that will return all these results similar to below? Prod_ID Prod_name Feat_1_value Feat_2_value feat_3_value 1 prod1 34 25 15 2 prod2 10 15 15 ... does this all make sense?

« previous php.db (#20195) next »