cinema pichodu Posted July 19, 2012 Report Posted July 19, 2012 i have 2 tables. emp and extemp. emp lo col name id and extemp lo col name emp_id but both values are same. ippudu naaku ee rendu tables lo unna row ni oke sari delete cheyadaniki query kavali. for ex : emp.id = 1111 aithe extemp table lo unna emp_id kuda 1111 now how to delete this row.......plz help bayyas........ [b] [url="http://forum.springsource.org/showthread.php?102729-Cannot-delete-or-update-a-parent-row-a-foreign-key-constraint-fails"]Cannot delete or update a parent row: a foreign key constraint fails[/url] [/b] ane error vasthundi...
Vaampire Posted July 19, 2012 Report Posted July 19, 2012 delete from [color=#282828][font=helvetica, arial, sans-serif][size=4]extemp where [/size][/font][/color][color=#282828][font=helvetica, arial, sans-serif] emp_id = @id[/font][/color] delete from [color=#282828][font=helvetica, arial, sans-serif]emp[/font][/color][color=#282828][font=helvetica, arial, sans-serif][size=4] where [/size][/font][/color][color=#282828][font=helvetica, arial, sans-serif] id = @id[/font][/color]
Guest Posted July 19, 2012 Report Posted July 19, 2012 1)First drop the constraint in child table the you can delete records in both tables at once 2 )first delete the record in child table and then in parent delete from child where x = x Go delete from paretn where x=x Go
Recommended Posts