473,386 Members | 1,785 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,386 software developers and data experts.

SQL Delete Problem (mysql)

Here's on for you, any help would be greatly appreaciated as it is
sending me mad...

I have three tables tbl_photo, tbl_photo_gallery and tbl_gallery.
they are linked through primary and and secondary keys as follows:

tbl_photo.photo_id = tbl_photo_gallery.photo_id
tbl_gallery.gallery_id = tbl_photo_gallery.gallery_id

yeat when i try this delete it fails:

delete from tbl_photo where tbl_photo.photo_id =
tbl_gallery_photo.photo_id and tbl_gallery_photo.gallery_id = (number)

I tried putting this directly into mysql and got the following error:

Unknown table 'tbl_gallery_photo' in where clause

the table definately exists as 'select * from tbl_gallery_photo' works
fine.

If anyone can help I will buy them a pint one day... please?
Jul 20 '05 #1
2 1917
TomyB wrote:
delete from tbl_photo where tbl_photo.photo_id =
tbl_gallery_photo.photo_id and tbl_gallery_photo.gallery_id = (number)


You need a syntax similar to this example:

DELETE test FROM test AS t1, test2 WHERE ...

But you should also know that multi-table-delete doesn't work with older
versions of MySQL. You didn't mention what version you are using so
can't say if it works for you, but you can read it for yourself from the
manual. Direct link to correct page below:

http://dev.mysql.com/doc/mysql/en/DELETE.html
Jul 20 '05 #2
TomyB ??:
Here's on for you, any help would be greatly appreaciated as it is
sending me mad...

I have three tables tbl_photo, tbl_photo_gallery and tbl_gallery.
they are linked through primary and and secondary keys as follows:

tbl_photo.photo_id = tbl_photo_gallery.photo_id
tbl_gallery.gallery_id = tbl_photo_gallery.gallery_id

yeat when i try this delete it fails:

delete from tbl_photo where tbl_photo.photo_id =
tbl_gallery_photo.photo_id and tbl_gallery_photo.gallery_id = (number)

I tried putting this directly into mysql and got the following error:

Unknown table 'tbl_gallery_photo' in where clause
The table name you defined above is 'tbl_photo_gallery '. the table definately exists as 'select * from tbl_gallery_photo' works
fine.

If anyone can help I will buy them a pint one day... please?


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: NotGiven | last post by:
I'd like to delete a record and all its children records at one time. How do I do that? Can you, in one SQL statement, delete from table 1 where id = 3 delete from table 2 where id = 12...
4
by: Chris | last post by:
Hi, sorry to post OT but i cant find the MySQL newsgroup, however i am hoping to pick up on some expert advice from php/mysql gurus here. I'm having some trouble performing a delete across two...
0
by: Gordon | last post by:
I have 2 tables t and t1. In this case, t1 is a copy of t. I want to delete rows from t1 based on criteria on the t table and a relationship between t ad t1 (in this case the id column). In the...
2
by: michael | last post by:
Gotta post because this is driving me nuts. Trying to DELETE orphans. I can successfully: SELECT GroupID FROM Groups LEFT JOIN Users ON UsersID = UserID WHERE UsersID IS NULL; but when I...
5
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB...
5
by: Mike | last post by:
I am not a sql person and could use some help with a delete...here is what I want: I have the following tables/fields (only including necessary fields) answers result_id results result_id
3
by: saracen44 | last post by:
Hi I have MyISAM tables When I'm deleting parent I want to delete children in the same time. How can I do It? What are possibilities? Thanks
4
by: Stephen | last post by:
Hello People, Using MS Access 2003 VBA I get the error 3020 Update or CancelUpdate without AddNew or Edit when I run through the following code. Can anyone help suggest anything to try? Thanks....
8
by: starman7 | last post by:
i have a table with objects in categories and their positions. there will be several rows with category 400, and they will have various positions, i want to delete only the row with the lowest...
9
by: Dejan | last post by:
Hy, Sorry for my terreble english I have this simple code for deleting rows in mysql table... Everything works fine with it. So, what do i wanna do...: my sql table looks something like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...

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.