Results 1 to 2 of 2
  1. #1
    Join Date
    May 2010

    Unanswered: Delete query to delete records from multiple tables having many-to-one relation


    I have 4 table,
    1. t_Config - PK_Conf_id -> FK_Link_id, FK_int_id, FK_Coi_id
    2. t_link - PK_Link_id -> FK_Conf_id
    3. t_int_link - PK_int_id ->FK_Conf_id, FK_Link_id,
    4. t_coi_link - PK_Coi_id -> FK_Conf_id, FK_int_id

    PK - Primary Key
    FK - Foreign Key

    first table t_Config having foreign key from all other 3 tables
    and other three tables have foreign key from first table
    All foreign keys from above tables allow null value
    t_Config table is main table, Its having atleast one foreign key value present.
    From other three tables at least one should have record with FK_Conf_id value from t_Config table.

    I am not able to delete it individualy, How I can delete records from above tables?

    Please help.

    Vikas Tayde

  2. #2
    Join Date
    Jun 2010
    1. Drop foreign key (FK_Conf_id) constraint first from the last 3 tables.
    2. Delete rows from 1st table and then delete same rows from other 3 tables.

    That should solve the problem


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts