Takes an id from the users table, and searches the phones_user table phones_user this id in the id_users column, if it id_users , it deletes the record.

There is such a query: DELETE FROM phones_users WHERE id_user = 213 it works.

  Таблица `users` +-----+-----------------+---------------+ | id | user_first_name | user_last_name| +-----+-----------------+---------------+ | 213 | Eugen | Podlevskykh | +-----+-----------------+---------------+ | 214 | Dima | Mukhin | +-----+-----------------+---------------+ 

 Таблица `phones_users` +-----+-----------+------------+ | id | id_user | phone_1 | +-----+-----------+------------+ | 180 | 213 | 0993331285 | +-----+-----------+------------+ | 181 | 214 | 3663223345 | +-----+-----------+------------+ 

This one no

  DELETE `users`, `phones_users` FROM `users` JOIN `phones_users` ON users.id = phones_users.id_user WHERE phones_users.id = 213 

The request is made, there are no errors, and the answer comes:

 Затронуто 0 строк. (Запрос занял 0,0000 сек.) 
  • 2
    Maybe meant WHERE phones_users.id_user = 213 instead of the filter by id? Well, or WHERE users.id = 213 - Minor
  • In the displayed source data there is no record with phones_users.id = 213 . - Akina
  • Thank you, I saw that instead of WHERE phones_users.id = 213 you need WHERE users.id = 213 - Misha Podlevsky

0