4
Does anyone know where I’m going wrong? or if it’s possible to do this?
I wrote the query like this:
DELETE FROM reservas WHERE ID NOT IN (SELECT ID,IDORIGEM FROM reservas WHERE ID='387' and IDORIGEM='387');
The idorigem field always keeps the same value as the first record which is what I don’t want to be deleted.
example:
ID IDORIGEM
387 387
490 387
510 387
650 387
mysql is giving this error message:
1241 - Operand should contain 1 column(s)
so Bacco I think I made the query wrong way:
– Francisco
It happens. Over time you get the practice. The important thing in this case is to know that
!=
means "other than". That is, "delete the bookings records where the id is different from 387".– Bacco
hello Bacco. I ended up writing the wrong query. I edited the question again. You can see where I am missing please?
– Francisco
What I had answered from remains the solution to your problem. Subquery won’t help you at all, and that’s not how it’s used. I updated the answer, however.
– Bacco
If you have any questions, just let us know that I try to explain better. You can comment here that I add. For me it’s more important you understand the logic than just working.
– Bacco
blz. Bacco. Really you’re right. I understood yes. Thanks for the help.
– Francisco