LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-30-2007, 07:29 PM   #1
Melsync
Member
 
Registered: Sep 2005
Posts: 75

Rep: Reputation: 15
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
 
Old 03-30-2007, 07:43 PM   #2
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 31
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;
 
Old 03-31-2007, 06:59 AM   #3
Melsync
Member
 
Registered: Sep 2005
Posts: 75

Original Poster
Rep: Reputation: 15
it worked

it worked, thanks a lot!
 
  


Reply

Tags
delete, mysql, select, wildcard


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync syntax to skip directory, but copy select files.. tnicol Linux - Software 3 07-24-2007 06:40 AM
Mysql SELECT WHERE LIKE ivanatora Linux - Software 3 03-20-2005 12:43 PM
unable to delete route-syntax problem? dthacker Linux - Networking 4 10-14-2004 12:23 PM
Ownership/Permission and Delete Syntax MadDogE134 Linux - Newbie 8 06-09-2004 07:05 PM
SELECT on MySQL Help Gerardoj Programming 5 05-29-2004 03:17 AM


All times are GMT -5. The time now is 02:49 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration