DELETE bug

DELETE bug

am 25.04.2003 11:19:32 von UM

Hi, all!

http://www.mysql.com/documentation/mysql/bychapter/manual_Re ference.html#DELETE

DELETE [LOW_PRIORITY] [QUICK] FROM table_name
[WHERE where_definition]
[ORDER BY ...]
[LIMIT rows]

This query doesn't work:

DELETE FROM somelog WHERE user='jcole' ORDER BY timestamp LIMIT 1

You have an error in your SQL syntax near 'order by timestamp limit 1' at line 1


--- Even if I do: ---

CREATE TABLE somelog (
user varchar(8) DEFAULT '0' NOT NULL,
ts timestamp(14)
);

DELETE FROM somelog WHERE user='jcole' ORDER BY ts LIMIT 1


Peace, love and grease!


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org

Re: DELETE bug

am 25.04.2003 13:11:03 von Peter Zaitsev

On Fri, 2003-04-25 at 13:19, UM wrote:
> Hi, all!
>
> http://www.mysql.com/documentation/mysql/bychapter/manual_Re ference.html#DELETE
>
> DELETE [LOW_PRIORITY] [QUICK] FROM table_name
> [WHERE where_definition]
> [ORDER BY ...]
> [LIMIT rows]
>
> This query doesn't work:
>
> DELETE FROM somelog WHERE user='jcole' ORDER BY timestamp LIMIT 1
>
> You have an error in your SQL syntax near 'order by timestamp limit 1' at line 1

This is because you have "timestamp" as column name. If you wish such
column name you'll need to quote it but it's better to use not reserved
keyword name instead.

>
>
> --- Even if I do: ---
>
> CREATE TABLE somelog (
> user varchar(8) DEFAULT '0' NOT NULL,
> ts timestamp(14)
> );
>
> DELETE FROM somelog WHERE user='jcole' ORDER BY ts LIMIT 1

This example works exactly right.


--
MySQL 2003 Users Conf. -> http://www.mysql.com/events/uc2003/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Peter Zaitsev
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Full-Time Developer
/_/ /_/\_, /___/\___\_\___/ Moscow, Russia
<___/ www.mysql.com


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org