You are here: Re: need help on a mysql query « PHP Programming Language « IT news, forums, messages
Re: need help on a mysql query

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация