sql - foreign key: conflicted with foreign key constraint -


so have 2 tables related each other fk

appointment   {id, dept.id, datetime, sometable.id, sometableagain.id} task   {id, appointment.id, deptlead.id, taskname} deptlead   {id, name} 

so had alter appointment table foreignkey table. dropped keys (task_appointment_fk, appointment_sometable_fk, appointment_sometableagain_fk) altered table add new field , added again everything. last 2 got added no problems. while other 1 (task_appointment_fk) kept giving me message :

"alter table statement conflicted forien key constraint "dept_appointment". cconflict occurred in database "mydb" , table "appointment", column "id" 

so found solutions states there might rows on task has appointmentid value not exist on appointment table. tried inserting rows have same value right. still gives me same thing. thing , want delete rows task make easier doing have drop fks again , same thing on over other tables, , have lot of other tables..

need advice.

thanks!!

you can write query see values in foreign key table not have matching key record in primary key table .if values there try delete them .

select   *     [task] left join [appointment] b  on       a.appointment_id = b.id 

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -