Re: MySQL query from multiple tables
| From: | Matthew Crouch | Date: | Thu, 04 Jul 2002 13:33:12 +0000 |
| Subject: | Re: MySQL query from multiple tables | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20317@lists.php.net to get a copy of this message | ||
it sounds like you may be serializing your SQL, in which case the following link might
help.
http://www.ashleyit.com/rs/jsrs/select/php/select.php
Matthew Nock wrote:
> 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?