DELETE FROM songs WHERE songs.id_album = album.id AND album.id_band =16`
Error: #1054 - Unbekanntes Tabellenfeld 'album.id' in where clause.
album exists, field
id too, 100%.
Where is error?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
You can't use the
album table because it isn't actually included in the query. (in the
FROM clause). You need to do this instead:
DELETE songs.* FROM songs JOIN album ON album.id = songs.id_album WHERE album.id_band = 16
See the section titled Multi-Table Deletes in the documentation for DELETE.
Alternatively, you could use WHERE EXISTS:
DELETE FROM songs WHERE EXISTS (SELECT * FROM album WHERE id_band = 16 AND id = songs.id_album)