Re: Stil having problems (WAS : Problem with links....)

From: Date: Mon, 24 Feb 2003 23:24:55 +0000
Subject: Re: Stil having problems (WAS : Problem with links....)
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-18806@lists.php.net to get a copy of this message
Sorry, in my application, i have something similar ; my table "data" has an id (auto increment), name ,etc. What i need is to show the name of the most recently entered id. My Sql sintax is: "SELECT name FROM data WHERE id=MAX(id)" But i have an error displaing: "Invalid use of group function" any help please?? "Neil Smith" <neil@fresh-toast.uklinux.net> escribió en el mensaje news:5.2.0.9.0.20030228151300.00a8ab08@mail.uklinux.net... > Hi - check your SQL : I think what you have here is a select asking for > MAX(ID) which will return one result (this is what MAX does). > > So, no need to ask for WHERE id IN (SELECT(MAX(ID)) but instead ask for > SELECT id=MAX(ID). > > If you wanted top n instead, ask for > SELECT id FROM data ORDER BY id DESC LIMIT 0,n > > Probably. What are you actually trying to print out ? > > HTH > Neil Smith. > > At 13:26 28/02/2003 +0000, you wrote: > >I'm still having problems : > > > >My query : > >$q = "SELECT id, computer_id, date, domain, ip, license_key, software, wm_id > >FROM data WHERE id IN (SELECT MAX(ID) FROM data GROUP BY Computer_ID) " . > >$Where_Text . " ORDER BY Domain, Date DESC"; >

« previous php.windows (#18806) next »