SQL DELETE with LEFT JOIN and Additional SELECT Statement
This SQL statement deletes data from multiple tables (hospital, doctor, posts, registration) using LEFT JOINs and a WHERE clause to target specific records. It also includes an additional SELECT statement to retrieve a specific value "1" after the DELETE operation. \n\nOriginal Statement:\n\nDELETE hospital, doctor, posts, registration\nFROM hospital\nLEFT JOIN doctor ON hospital.id = doctor.host_id\nLEFT JOIN posts ON doctor.id = posts.doctor_id\nLEFT JOIN registration ON doctor.id = registration.doctor_id\nWHERE hospital.id = 11;\n\nModified Statement with Additional SELECT:\n\nDELETE hospital, doctor, posts, registration\nFROM hospital\nLEFT JOIN doctor ON hospital.id = doctor.host_id\nLEFT JOIN posts ON doctor.id = posts.doctor_id\nLEFT JOIN registration ON doctor.id = registration.doctor_id\nWHERE hospital.id = 11;\n\nSELECT "1";
原文地址: https://www.cveoy.top/t/topic/qd3N 著作权归作者所有。请勿转载和采集!