| | |
MySQL Error 1064 when DELETEing
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Aug 2004
Posts: 24
Reputation:
Solved Threads: 0
I'm trying to carry out the following delete statements
but i am getting the error:
any idea what is causing this because everything looks okay to me.
Thanks in advance
MySQL Syntax (Toggle Plain Text)
DELETE FROM images AS i WHERE i.image_id = 803 AND i.plant_num = 2277 LIMIT 1 DELETE FROM images AS i WHERE i.image_id = 804 AND i.plant_num = 2277 LIMIT 1 DELETE FROM images AS i WHERE i.image_id = 805 AND i.plant_num = 2277 LIMIT 1
but i am getting the error:
MySQL Syntax (Toggle Plain Text)
1064: 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 'AS i WHERE i.image_id = 803 AND i.plant_num = 2277 LIMIT 1; DELETE FROM images A' at line 1
any idea what is causing this because everything looks okay to me.
Thanks in advance
Last edited by ray_broome; May 7th, 2008 at 3:21 pm.
•
•
Join Date: Dec 2007
Posts: 190
Reputation:
Solved Threads: 25
Write statements without aliase e.g.
MySQL Syntax (Toggle Plain Text)
DELETE FROM images WHERE image_id = 803 AND plant_num = 2277 LIMIT 1;
•
•
Join Date: Aug 2004
Posts: 24
Reputation:
Solved Threads: 0
thanks, i tried doin that but still get the same basic error.
Query:
Error:
and here's a PHP snippet:
Query:
MySQL Syntax (Toggle Plain Text)
DELETE FROM images WHERE image_id = 803 AND plant_num = 2277 LIMIT 1; DELETE FROM images WHERE image_id = 804 AND plant_num = 2277 LIMIT 1; DELETE FROM images WHERE image_id = 805 AND plant_num = 2277 LIMIT 1;
Error:
MySQL Syntax (Toggle Plain Text)
Could NOT UPDATE the database: 1064: 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 '; DELETE FROM images WHERE image_id = 804 AND plant_num = 2277 LIMIT 1; DELETE F' at line 1
and here's a PHP snippet:
MySQL Syntax (Toggle Plain Text)
foreach($removals as $id) $sql .= "\nDELETE FROM images WHERE image_id = ".$id." AND plant_num = ".$_REQUEST['pid']." LIMIT 1;";
Last edited by ray_broome; May 7th, 2008 at 4:49 pm.
•
•
Join Date: Sep 2007
Posts: 176
Reputation:
Solved Threads: 20
What does your PHP query statement print out as? I'm betting it's not what you think it is.
Also, a would help us help you.
Also, a
MySQL Syntax (Toggle Plain Text)
DESCRIBE images
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
"Others make web sites. We make web sites work!"
•
•
Join Date: Aug 2004
Posts: 24
Reputation:
Solved Threads: 0
well the query i showed you is what prints out.
and describe images is:
MySQL Syntax (Toggle Plain Text)
DELETE FROM images WHERE image_id = 803 AND plant_num = 2277 LIMIT 1; DELETE FROM images WHERE image_id = 804 AND plant_num = 2277 LIMIT 1; DELETE FROM images WHERE image_id = 805 AND plant_num = 2277 LIMIT 1;
and describe images is:
MySQL Syntax (Toggle Plain Text)
FIELD Type NULL Key DEFAULT Extra image_id INT(10) UNSIGNED NO PRI NULL AUTO_INCREMENT plant_num INT(10) UNSIGNED NO MUL NULL image_src VARCHAR(255) NO NULL image_alt VARCHAR(64) NO NULL location_taken VARCHAR(64) YES Barbados is_vouchered TINYINT(1) NO 0 is_best_fit TINYINT(1) NO 0
Last edited by ray_broome; May 7th, 2008 at 5:39 pm.
•
•
Join Date: Sep 2007
Posts: 176
Reputation:
Solved Threads: 20
What does
show you? If you can't find that image, then obviously you can't delete it.
MySQL Syntax (Toggle Plain Text)
SELECT * FROM images WHERE image_id = 803 AND plant_num = 2277\G
show you? If you can't find that image, then obviously you can't delete it.
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
"Others make web sites. We make web sites work!"
•
•
Join Date: Aug 2004
Posts: 24
Reputation:
Solved Threads: 0
nope i get back a result
btw i'm connecting as a user with delete priviliges so it isnt that either
i thought it might be the "\n" in the sql string perhaps but i took it out and still got the error
thanks for the assistance so far, i hope someone can help cause i reallly need to try and get this finished up soon
btw i'm connecting as a user with delete priviliges so it isnt that either
i thought it might be the "\n" in the sql string perhaps but i took it out and still got the error
thanks for the assistance so far, i hope someone can help cause i reallly need to try and get this finished up soon
•
•
Join Date: Sep 2007
Posts: 176
Reputation:
Solved Threads: 20
Can you execute
from the command line?
Can you execute that literal string from your script?
Your script might not have the same permissions you do from the command line. Do other of your scripts execute OK when accessing the database?
1064 seems to refer to using a reserved word, but I see none in your query.
MySQL Syntax (Toggle Plain Text)
DELETE FROM images WHERE image_id = 803 AND plant_num = 2277 LIMIT 1;
Can you execute that literal string from your script?
Your script might not have the same permissions you do from the command line. Do other of your scripts execute OK when accessing the database?
1064 seems to refer to using a reserved word, but I see none in your query.
Last edited by trudge; May 7th, 2008 at 7:33 pm.
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
"Others make web sites. We make web sites work!"
•
•
Join Date: Aug 2004
Posts: 24
Reputation:
Solved Threads: 0
Hi thanks for all the previous help but i've figured it out.
This is the php/sql query i use now:
php:
query
I'm not sure why, but MySQL didnt seem to like when i put DELETE statements one after the other like that
This is the php/sql query i use now:
php:
MySQL Syntax (Toggle Plain Text)
$sql .= "\nDELETE FROM images WHERE plant_num = ".$_REQUEST['pid']." AND image_id IN (".implode(",",$removals).");";
query
MySQL Syntax (Toggle Plain Text)
DELETE FROM images WHERE plant_num = 2277 AND image_id IN (803,804,805);
I'm not sure why, but MySQL didnt seem to like when i put DELETE statements one after the other like that
Last edited by ray_broome; May 7th, 2008 at 8:04 pm.
![]() |
Other Threads in the MySQL Forum
- Previous Thread: Insert doesn't do what it's supposed to
- Next Thread: mySQL TRIGGER problem
| Thread Tools | Search this Thread |
agplv3 amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





