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

Posted by Erwin Moller on 11/21/07 16:05

SBmx wrote:
> hello

Hi,

Not excactly a PHP question, but here we go.

>
> I need help building a SELECT query... well, two queries actually
>
> i have three tables:
>
> products / fields id, name, type, country
> producttypes / fields: id, name
> countries / fields: id, name
>
> as you probably guessed, products.type stores a value from
> producttypes.id and products.country stores a value from countries.id

Nope, I wouldn't have guessed that.
I always give columns the same name if I create a Foreign Key constraint.
But clear now. :-)

>
> now, in my first query i need to select all producttypes that have
> more than 0 products belonging to that category.

Try using GROUP BY and use HAVING

>
> in a subsequent query i'll have to select all countries that have more
> than 0 products which belong to a given producttype.

Same: GROUP BY and HAVING.

>
> Thanks for taking the time to help me solve this one..

You'll have to solve it yourself, but you know what to look for now. ;-)

>
> somaBoy MX
>

Good luck.

Regards,
Erwin Moller

 

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

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