mysql - Sql query only functions if all records exist -
delete profile, images, schedules using profile inner join images using(profile_id) inner join schedules using(profile_id) profile.profile_id = 47
i have piece of mysql code deletes records has profile 47. let's schedules doesn't have 47, whole query doesnt delete other records other tables.
basically want delete regardless of whether or not schedules has record.
the other option query database check schedules table before doing delete query?
use outer join access tables might not have supporting records:
delete p, i, s using profile p left join images on i.profile_id = p.profile_id left join schedules s on s.profile_id = p.profile_id p.profile_id = 47
here's good primer on joins.
Comments
Post a Comment