Reply to Re: Can it be done ?

Your name:

Reply:


Posted by Stefan Rybacki on 04/01/06 04:39

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

laptop schrieb:
> Sorry, that should read "given that Strawberry's query...".
>
> Confusing hunh?

The answer to your question "why is this query wrong" is,
that if you're using the GROUP BY clause your SELECT clause can just
contain the columns that are used in the GROUP BY clause and any other
column has to be used within an aggregat function like MAX, MIN, COUNT etc.
That it works without aggregate function in mySQL is true but its like
using an aggregate function like GIVERANDOMVALUE out of the column. The
result is unpredictable and that it worked in your case is just by
accident. That can be different in another version or might be different
on another computer or OS.

Do you like an example? See this table

NO. name
1 Stefan
1 laptop
1 s

So what I do now is this:

SELECT name FROM table GROUP BY NO.

So what do you think which name appears at the end? Think about it ...


Regards
Stefan

> ...
>>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (MingW32)

iD8DBQFELdncyeCLzp/JKjARAuuvAKCNL7BrtXuwJ/2Gu+mIt3xZQOvWGQCfVRHh
F/We8g3CinNfDrh+3EhxnuM=
=oMis
-----END PGP SIGNATURE-----

[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

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