Arsip: Bagaimana cara hapus data dengan dua tabel menggunakan SQL

 
user image
more 12 years ago

onsir

misal data master spt ini tgl nofak 2006-02-02 N001 2006-04-4 N002 2007-05-23 N034 data detail nofak kodebrg N001 B1 N001 B2 N002 B7 N034 B2 saya ingin hapus data di tabel master dan detail, dengan kriteria hapus semua data di tabel master dan detail di mana tgl <2006-12-31 sy menggunkan MySQL 5 Terima kasih
user image
more 12 years ago

DelphiExpert

1. DELETE DETAIL WHERE NOFAK IN (SELECT NOFAK FROM MASTER WHERE TGL < 2006-12-31) 2. DELETE MASTER WHERE TGL < 2006-12-31 NB. sesuaikan sintak utk komparasi tanggal :mrgreen:
user image
more 12 years ago

yayaretina

pake foreign key di table detail, set on delete rule = CASCADE. cukup delete pada table master. klo kurang jelas... bukan di mysql reference. lengkap banget disitu.. klo masih kurang.. download white papernya.. :D
user image
more 12 years ago

dels

pake foreign key di table detail, set on delete rule = CASCADE. cukup delete pada table master.
tambahan: coba sekalian belajar yg namanya Referential Integrity supaya mengerti konsep master-detail yg "benar" :D
more ...
  • Pages:
  • 1
Share to
Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com