Hi Peter, On Fri, 2002-09-20 at 08:03, Peter M. Flor wrote: > I have been beating my head against a wall to try and get this to work. > Apparently in version 2.22 a bug preventing ORDER BY in a SELECT statement > from working was fixed in 2.23. Well I think that this bug also exists in > 2.23 when using ORDER BY in conjunction with a DELETE statement, and > possibly others. > > My code yields an SQL syntax error "near" the order by statement: > > DELETE FROM sessions WHERE userid=someuser ORDER BY sessionid DESC LIMIT > somenumber; > > I'm using php, here is the actual code as it is written in my script: > > mysql_query( "DELETE * FROM sessions WHERE userid=$userid ORDER BY sessionid > DESC LIMIT $numrows" ); > > During my research i found an example of code at > http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#DEL > ETE with an example of code that in function resembles my code almost > exactly.
The same page contains a note that ORDER BY in DELETE is supported from MySQL version 4.0. So if you grab a 4.0 from www.mysql.com, you will find that your query will work just fine! Regards, Arjen. -- MySQL Training, Support, Licenses @ https://order.mysql.com/?marl __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Mr. Arjen G. Lentz <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Technical Writer, Trainer /_/ /_/\_, /___/\___\_\___/ Brisbane, QLD Australia <___/ www.mysql.com --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php