By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,882 Members | 928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,882 IT Pros & Developers. It's quick & easy.

SQL Delete Problem (mysql)

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.