Welcome Guest, Not a member yet? Register   Sign In
delete from two tables in one query
#1

[eluser]erviando[/eluser]
i have two tables

Topik table
Code:
topik_id
topik_nama
topik_nim
topik_judul
topik_abstrak
topik_pembimbing1
topik_pembimbing2

Jadwal table
Code:
jadwal_id
jadwal_nim
jadwal_tanggal
jadwal_ruang

$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?
#2

[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.
#3

[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
#4

[eluser]erviando[/eluser]
:-)thank you all....

i have found solution with LEFT JOIN my two tables... :-D




Theme © iAndrew 2016 - Forum software by © MyBB