Re: MySQL Query Help
| From: | Richard West | Date: | Sat, 20 Nov 2010 21:07:13 +0000 |
| Subject: | Re: MySQL Query Help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309590@lists.php.net to get a copy of this message | ||
I'm going to jump in and throw in my 2 cents...
Have you used dreamweaver?
I would suggest Dreamweaver to any new programmer beginning php/mysql.
It helped me out tremendously in the beginning. I'm not an advanced programmer with hand coding
classes yet, but I can get any job completed for clients with dreamweaver. Custom content management
systems, image galleries from mysql etc...
Give it a try, It lets you add the the prewritten code and then you can switch to code view and see
whats its doing.
RD
On Nov 20, 2010, at 3:54 PM, Ben Miller wrote:
> Hi,
>
> I'm building a website for a client in which I need to compare their
> products, side-by-side, but only include criteria for which all selected
> products have a value for that criteria.
>
> In my database (MySQL), I have a tables named "products","criteria" and
> "criteria_values"
>
> If I have something like
>
> $selected_product = array("1"=>"Product
> 1","2"=>"Product 2"...) // All
> products selected for comparison by the user
>
> I need to get only rows from "criteria" where there is a row in
> "criteria_values" matching "criteria.criteria_id" for each
> $selected_product
> - in other words, if any of the $selected_product does not have a row in
> "criteria_values" that matches "criteria.criteria_id", that criteria would
> not be returned. I hope that makes sense.
>
> I've played around with a few join queries, but none have given the desired
> results. Best I've been able to come up with so far is to query "criteria"
> for each DISTINCT(criteria_id) and then run through each $selected_product
> to make sure each has a criteria_value with a matching criteria_id,
> eliminating any criteria where the number of criteria_values <
> count($selected_product), but this seems pretty inefficient.
>
> Thanks in advance for any help.
>
> Ben Miller
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>