Re: [PHP-DB] MySQL SQL Query Help

2006-11-13 Thread Chris
Peter Beckman wrote: On Mon, 13 Nov 2006, [EMAIL PROTECTED] wrote: Actually, that should not work, it should give you an error. This should work: SELECT `fkid`,max(`foo`) as foo,`bar` FROM `test2` GROUP BY `fkid` ORDER BY `bar` ASC Yes, but if the data is in a different order that fails a

Re: [PHP-DB] MySQL SQL Query Help

2006-11-13 Thread Peter Beckman
On Mon, 13 Nov 2006, [EMAIL PROTECTED] wrote: Actually, that should not work, it should give you an error. This should work: SELECT `fkid`,max(`foo`) as foo,`bar` FROM `test2` GROUP BY `fkid` ORDER BY `bar` ASC Yes, but if the data is in a different order that fails and doesn't maintain r

Re: [PHP-DB] MySQL SQL Query Help

2006-11-13 Thread [EMAIL PROTECTED]
Actually, that should not work, it should give you an error. This should work: SELECT `fkid`,max(`foo`) as foo,`bar` FROM `test2` GROUP BY `fkid` ORDER BY `bar` ASC Miguel Guirao wrote: > select max(bar) from mytable where unique fkid order by bar asc > > as far as I remember!! > > -Ori

RE: [PHP-DB] MySQL SQL Query Help

2006-11-13 Thread Miguel Guirao
select max(bar) from mytable where unique fkid order by bar asc as far as I remember!! -Original Message- From: Peter Beckman [mailto:[EMAIL PROTECTED] Sent: Lunes, 13 de Noviembre de 2006 04:59 p.m. To: PHP-DB Mailing List Subject: [PHP-DB] MySQL SQL Query Help I have a table: id fk

Re: [PHP-DB] MySQL SQL Query Help

2006-11-13 Thread Niel Archer
Hi Try: SELECT fkid, MAX(foo), bar FROM table GROUP BY fkid ORDER BY bar DESC Niel -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php