473,761 Members | 7,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MySQL Error 1064 when DELETEing

9 New Member
Hi,

I'm getting an error 1064 when trying to delete some rows from a table.

SQL is:
Expand|Select|Wrap|Line Numbers
  1. DELETE FROM images WHERE image_id = 803 AND plant_num = 2277 LIMIT 1;
  2. DELETE FROM images WHERE image_id = 804 AND plant_num = 2277 LIMIT 1;
  3. DELETE FROM images WHERE image_id = 805 AND plant_num = 2277 LIMIT 1;
  4.  
Error is:
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
PHP is:
[PHP]foreach($remova ls as $id)
$sql .= "\nDELETE FROM images WHERE image_id = ".$id." AND plant_num = ".$_REQUEST['pid']." LIMIT 1;"; [/PHP]
May 7 '08 #1
3 2932
ronverdonk
4,258 Recognized Expert Specialist
You are generating a multi-SQLstatement. That is not allowed in Mysql. So you will have to execute each DELETE statement after you generated it, like[php]foreach($remova ls as $id)
mysql_query("DE LETE FROM images WHERE image_id=$id AND plant_num = ".$_REQUEST['pid']." LIMIT 1");
[/php]Ronald
May 7 '08 #2
Atli
5,058 Recognized Expert Expert
If you want to execute multiple queries in one go, the MySQL Improved Extension (mysqli) can do so via the mysqli::multi_q uery method.
May 7 '08 #3
Atli
5,058 Recognized Expert Expert
Although...
In your case it would probably be better to use a single query, using the IN() function.
Like for example:
Expand|Select|Wrap|Line Numbers
  1. DELETE FROM myTable WHERE myTable.ID IN(1, 2, 4, 6, 8)
  2.  
May 7 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
654
by: Morten Gulbrandsen | last post by:
Hi programmers, I try to investigate some of the basics behind schemas and cataloges, Which is part of SQL2 Language this is the error message I get:
0
2982
by: Kenneth Illingsworth | last post by:
--=_603E7359.5B3A569C Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I suspect that this is some kind of issue with privileges. However, the = account I am using has been given 'ALL' privileges to the database I am = trying to insert to. Am I save to assume that ALL includes insert = privileges?
0
5003
by: Fatt Shin | last post by:
Hi, I'm running MySQL 4.0.13, connecting from PowerBuilder 9 using ODCB Connector 3.51. I'm facing a problem where whenever I issue a SELECT COUNT(*) statement from PowerBuilder, I always get SQL syntax error back from MySQL. (Refer to ODBC Trace I captured below). metrohouse af8-b94 ENTER SQLExecDirect HSTMT 014D2360 UCHAR * 0x020A0EA2 "select count ( *) from code
0
2369
by: Mario Ohnewald | last post by:
Hello! I want to import a MySQL 3.x Databse to my new shiny MySQL4.x. I did a backup with /usr/local/mysql-standard-4.0.14-pc-linux-i686/bin/mysqldump -u root -p --opt -A > mysql_lamp_backup.`date '+%Y.%m.%d'`.sql And i tried to import it to MySQL4.x with: /usr/local/mysql/bin/mysql -u root -p < mysqlbak The error: ERROR 1064 at line 598: You have an error in your SQL syntax. Check the
4
5852
by: Adam Smith | last post by:
I have a dedicated server running 'FreeBSD 4.9 STABLE' at a hosting site. They have done some default installations, presumably from the CVS ports package ??. Herein lies the problem, "I do not know" what they have done! At first it was apparent that MySQL was installed mysql_install_db ; GRANT TABLES etc. ??? so I ran "mysql_install_db --force"
13
12238
by: wideangle | last post by:
Hello there! I know it's stupid, but when creating a table in a mysql (win32) database, it won't let me create this "mytable". Here goes my ER_PARSE_ERROR. mysql> CREATE TABLE `mytable` ( -> `mytable_id` int(25) NOT NULL auto_increment, -> `mytable_title` varchar(100) NOT NULL default '', -> `mytable_dts` varchar(25) NOT NULL default '',
3
2312
by: Thiagu.M | last post by:
Hi All i dont have much experience in databases or Mysql.i have my data in development m/c with Mysql 4.1.12, i have to move them to production m/c with Mysql 5.0.3 .when tried it showed error with displaying # mysql -u root mydatabase < backup1.sql ERROR 1064 (42000) at line 1: 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 'r o
39
5869
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f ISO-8859-1 -t UTF-8 mydb.sql mydb_utf8.sql mysqlCREATE DATABASE mydb_utf8 CHARACTER SET utf8 COLLATE utf8_general_ci;
2
4314
by: amaddox | last post by:
When I run this query from PHPMyAdmin, it works: DELETE FROM `tbl_user_link` WHERE ((`ulUserID`!=3 AND `ulConnectID`! =1) AND (`ulUserID`!=18 AND `ulConnectID`!=23)) AND `ulTypeID`=10 AND `ulOtherID`=160 However, when I run it from my application, I get a MySQL error 1064. Any ideas?
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.