473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Getting error No. 1064... Deleting from multiple tables

Hi all,

Whats wrong with this syntax?
Expand|Select|Wrap|Line Numbers
  1. DELETE from fighterSponsor fs, sponsors s, imageData id where fs.sponsorId=s.sponsorId AND id.imageId=s.imageId AND (s.imageId=81 OR s.imageId=82)
I keep getting errors:

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 'where fs.sponsorId=s.sponsorId AND id.imageId=s.imageId AND (s.imageId=81 OR s.i' at line 1

Thanks

Al
Sep 21 '07 #1
4 2459
pbmods
5,821 Expert 4TB
Heya, Al.

When you DELETE from multiple tables, you must also specify which tables you are deleting from:
Expand|Select|Wrap|Line Numbers
  1. DELETE
  2.         `fs`.*,
  3.         `s`.*,
  4.         `id`.*
  5.     FROM
  6.     (
  7.             `fighterSponsor`
  8.                 AS `fs`
  9.         INNER JOIN
  10.             `sponsors`
  11.                 AS `s`
  12.         INNER JOIN
  13.             `imageData`
  14.                 AS `id`
  15.     )
  16.     WHERE
  17.     (
  18.             `fs`.`sponsorId` = `s`.`sponsorId`
  19.         AND
  20.             `id`.`imageId` = `s`.`imageId`
  21.         AND
  22.         (
  23.                 `s`.`imageId` = 81
  24.             OR
  25.                 `s`.`imageId` = 82
  26.         )
  27.     )
  28.  
Sep 21 '07 #2
mwasif
802 Expert 512MB
Moved to MySQL forum.
Sep 22 '07 #3
Heya, Al.

When you DELETE from multiple tables, you must also specify which tables you are deleting from:
Expand|Select|Wrap|Line Numbers
  1. DELETE
  2.         `fs`.*,
  3.         `s`.*,
  4.         `id`.*
  5.     FROM
  6.     (
  7.             `fighterSponsor`
  8.                 AS `fs`
  9.         INNER JOIN
  10.             `sponsors`
  11.                 AS `s`
  12.         INNER JOIN
  13.             `imageData`
  14.                 AS `id`
  15.     )
  16.     WHERE
  17.     (
  18.             `fs`.`sponsorId` = `s`.`sponsorId`
  19.         AND
  20.             `id`.`imageId` = `s`.`imageId`
  21.         AND
  22.         (
  23.                 `s`.`imageId` = 81
  24.             OR
  25.                 `s`.`imageId` = 82
  26.         )
  27.     )
  28.  

Worked like a charm!

Thanks
Sep 23 '07 #4
pbmods
5,821 Expert 4TB
Heya, Al.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Sep 23 '07 #5

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

Similar topics

0
by: Ola Ogunneye | last post by:
--=_104E0413.12733F99 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit I am running mysql 4.0.13 and using a weblog(Geeklog) to do my web. Using geeklog as been okay...
0
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
13
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` ( ->...
5
by: Alex | last post by:
Hi, I have two tables , A and B where table B has a foreign key constraint to table A. I want to delete all records in table A that are older than a certain date that are not referenced by...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: BrianDP | last post by:
I have a database with a split front end/back end. There is a key table in the back end called Catalog, and it is sort of a central key table for all sorts of things. It's a list of all the jobs...
1
by: thomasjbs | last post by:
I'm trying to migrate a Wiki database to another server. I have zero problems backing up the database using multiple methods. But the Mysql restore fails with: ERROR 1064 at line 52: You have...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
1
by: sphinney | last post by:
All, I'm not sure how to adequately explain my problem in two sentences or less, so at the risk of providing TMI, here's the condensed verion. I have developed an Access 2002 database file that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.