delete from invoices where client_id = ( select* from clients where name = 'Myworks' );
I'm trying to delete a row of data for a client from another table called invoices, but it throws me an error 1241. What am I missing here?
delete from invoices where client_id = ( select* from clients where name = 'Myworks' );
I'm trying to delete a row of data for a client from another table called invoices, but it throws me an error 1241. What am I missing here?
Copyright © 2021 Jogjafile Inc.
When you do this:
If that
clientstable has more than one column, which column shouldclient_idbe compared to? MySQL doesn't know, and won't decide for you, and so it's giving you an error message.Specify one column for that identifier:
(This is assuming the target column is also called
client_id. Use whatever column you wish.)As an aside, using
=there is weird to me. I'm not sure if the system supports it, it may and this may be a non-issue. But if it doesn't, useINinstead. (Which just makes more sense to me semantically anyway.) For example: