How to delete record from two tables using sql qurey?

Discussion in 'C#' started by raspms, Mar 22, 2012.

  1. #1
    hello,
    i have two tables menu with menuid as pk and i also have another table named as submenu with submenuid as pk and menuid as fk.
    if i delete one menu then atomatically related their submenu also want to delete,,,
    can anybody tel me how can i write the sql querry for this operation..
    but i want a querry using join conditions...not a separate querries...
     
    raspms, Mar 22, 2012 IP
  2. Scarrfo

    Scarrfo Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't know what your schema looks like but an easy way to test this is using SQL Server Management Studio Express (free from Microsoft) and running a select query. Management studio will let you create queries with great ease.
    When the results are correct change the query to delete.

    Another way is to create a temp database with the same schema and populate a few records and test your SQL queries. I used this approach often when I was learning
     
    Scarrfo, Mar 28, 2012 IP
  3. aisyaziz

    aisyaziz Guest

    Messages:
    40
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you should probably look at triggers.
     
    aisyaziz, Mar 28, 2012 IP
  4. heloraghu

    heloraghu Member

    Messages:
    133
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #4
    delete table <tablename>; using this command we can delete any table.
     
    heloraghu, Mar 29, 2012 IP
  5. raspms

    raspms Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    but i want a querry using join conditions...not a separate querries...
     
    raspms, Apr 4, 2012 IP