|
Posted by Erwin Moller on 11/21/07 16:40
SBmx wrote:
> On Nov 21, 5:05 pm, Erwin Moller
> <Since_humans_read_this_I_am_spammed_too_m...@spamyourself.com> wrote:
>
>> Try using GROUP BY and use HAVING
>
>
> actually, i looked into subqueries and came up with this:
> SELECT name, id FROM countries WHERE id IN (SELECT country FROM
> products)
> SELECT name, id FROM producttypes WHERE id IN (SELECT type FROM
> products WHERE country=$intCountry)
>
Yes, that works in this situation.
But what will you do when you need all producttypes that have more than,
say, 2 or 3 products belonging to a certain category?
Have a look at GROUP BY and HAVING.
They are designed for this. ;-)
> seems to work, but your solution would probably be more backwards
> compatible with older mysql versions.
I don't know much about mySQL.
Last time I looked into it I ran away screaming (back to PostgreSQL).
I prefer PostgreSQL, as superior database compared to mySQL in my humble
opinion. (MySQL is a little faster, but that is all)
But I expect that mySQL can handle both approaches (subselect and GROUP BY).
>
> thanks a bunch!
You are welcome.
Good luck
Regards,
Erwin Moller
>
> somBoy MX
[Back to original message]
|