delete from two tables in one query - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: delete from two tables in one query (/showthread.php?tid=57411) |
delete from two tables in one query - El Forum - 03-12-2013 [eluser]erviando[/eluser] i have two tables Topik table Code: topik_id Jadwal table Code: jadwal_id $id=$this->uri->segment('3'); i want delete two tables in one query if topik_nim=jadwal_nim and topik_id=$id what shoul i do with my query? delete from two tables in one query - El Forum - 03-13-2013 [eluser]TheFuzzy0ne[/eluser] It's possible, but you're asking for trouble. What's wrong with using two queries? It makes a lot more sense, and you're less likely to delete stuff by accident. delete from two tables in one query - El Forum - 03-13-2013 [eluser]Otemu[/eluser] Hi, If your table has a foreign key constraint and are related, you could have a delete cascade on update, basically if you delete a field in one table it delete on the other. You could use what TheFuzzy0ne check out codeigniter transactions and finally you could use a join if the tables are related. Thanks hope that helps delete from two tables in one query - El Forum - 03-13-2013 [eluser]erviando[/eluser] :-)thank you all.... i have found solution with LEFT JOIN my two tables... :-D |