LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   MySQL the syntax to SELECT doesn't work for DELETE (http://www.linuxquestions.org/questions/programming-9/mysql-the-syntax-to-select-doesnt-work-for-delete-542035/)

Melsync 03-30-2007 07:29 PM

MySQL the syntax to SELECT doesn't work for DELETE
 
Hi,
I get to select the rows I need from a table with, for instance,
SELECT * FROM tbl_nge WHERE id BETWEEN 328 AND 512;
or
SELECT * from tbl_nge WHERE tags like "%org%";
but I can't delete the selected rows with the same syntax
DELETE * FROM tbl_nge WHERE id BETWEEN 328 AND 512;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM tbl_nge WHERE id BETWEEN 328 AND 512 at line 1

or
DELETE * FROM tbl_nge WHERE tags like "%org%";
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM tbl_nge WHERE tags LIKE "%org%"' at line 1

http://dev.mysql.com/doc/refman/5.0/en/delete.html says that the syntax of DELETE is the same as SELECT.

Thanks,
Mel.

mysql Ver 14.7 Distrib 4.1.20, for redhat-linux-gnu (i386) using readline 4.3

spirit receiver 03-30-2007 07:43 PM

You can only delete an entire row from a table, so the "*" doesn't make much sense. Try the following:
Code:

DELETE FROM tbl_nge WHERE id BETWEEN 328 AND 512;

Melsync 03-31-2007 06:59 AM

it worked
 
it worked, thanks a lot!


All times are GMT -5. The time now is 07:32 PM.