Answer the question
In order to leave comments, you need to log in
How to delete a row from 2 tables in one query?
I need to delete rows with Id = 80 in 2 tables, tell me what I'm doing wrong?
DELETE FROM table_1 A LEFT JOIN table_2 B ON (A.Id= B.Id) WHERE Id= '80' AND A.Type= '0'
Answer the question
In order to leave comments, you need to log in
DELETE
A,
B
FROM
table_1 A
LEFT JOIN table_2 B ON (A.Id= B.Id)
WHERE
A.Id=80
Hang up foreign key with property ON DELETE... CASCADE on the necessary column. Then the DBMS will automatically remove related data from other tables.
BEGIN;
DELETE FROM table_1 WHERE ID = 80;
DELETE FROM table_2 WHERE ID = 80;
COMMIT;
what am I doing wrong?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question