I have this code to delete data from multiple tables in one go:
DB::table('tb_stikes_register_school')->where('register_id', $_POST['id'])->delete();
DB::table('tb_stikes_register_guardian')->where('register_id', $_POST['id'])->delete();
DB::table('tb_stikes_register_student')->where('register_id', $_POST['id'])->delete();
I'm trying to shorten this into 1 query only, register_id from guardian
and school
tables is the foreign key of student
table. I've been trying to use join but only student
table record is deleted. Is there any workaround this?
Something like this maybe - haven't tested
Or you could use a fully raw query:
Basically recreating something similar to this: delete rows from multiple tables