Reply to Re: get data from 2 tables, 1 is a count

Your name:

Reply:


Posted by not_on on 10/31/05 00:17

On Thu, 27 Oct 2005 11:18:21 +0200, Stefan Rybacki
<stefan.rybacki@gmx.net> wrote:


>> got it working nearly :(
>>
>> select count(t1) as count,t2.* from t1,t2 where t1.id=ID and
>> t2.id=ID group by t1.id order by count
>>
>> BUT this only shows results from table 1 that also have soemhting in
>> table two... I need to show all results of table one even if nothing

>Use a LEFT JOIN!
> select count(t1) as count,t2.* from t1 LEFT JOIN t2 ON (t1.id=ID and
> t2.id=ID) group by t1.id order by count


That now works perfectly.. many thanks.

Why will it not accept a wildcard in count such as count( t1.*)
instead it needs a collum name.. not important.. just unexpected:)


I do have MySQL by Paul DuBois and its looking a bit ragged now I
have used it so much.. I just can't seem to get my head around the
join ..erk :( More reading and more testing I guess.

Many many thanks for your answer Stefan . Much appreciated.

[Back to original 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

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