Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to delete related Data/Rows.

How to delete related Data/Rows.

Scheduled Pinned Locked Moved Database
tutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abdul Rhman Alsri
    wrote on last edited by
    #1

    Ex: Tables: 1) Account: ID,UserName,Pass 2) Campaign: ID,AccountID,Date,Balance 3) CampaignSpec: ID,CampaignID,Spec,Color Note: Account.ID = Campaign.AccountID and Campaign.ID = CampaignSpec.CampaignID

    S 1 Reply Last reply
    0
    • A Abdul Rhman Alsri

      Ex: Tables: 1) Account: ID,UserName,Pass 2) Campaign: ID,AccountID,Date,Balance 3) CampaignSpec: ID,CampaignID,Spec,Color Note: Account.ID = Campaign.AccountID and Campaign.ID = CampaignSpec.CampaignID

      S Offline
      S Offline
      Simon_Whale
      wrote on last edited by
      #2

      delete a, b, c
      from Account as a inner join Campaign as b
      on a.[id] = b.[id] inner join CampaignSpec as c
      on b.[id] = c.campaignid

      and just include any where clause that you need else all will be deleted

      Marc Clifton wrote:

      That has nothing to do with VB. - Oh crap. I just defended VB!

      F 1 Reply Last reply
      0
      • S Simon_Whale

        delete a, b, c
        from Account as a inner join Campaign as b
        on a.[id] = b.[id] inner join CampaignSpec as c
        on b.[id] = c.campaignid

        and just include any where clause that you need else all will be deleted

        Marc Clifton wrote:

        That has nothing to do with VB. - Oh crap. I just defended VB!

        F Offline
        F Offline
        fjdiewornncalwe
        wrote on last edited by
        #3

        I would suggest the more "proper" way to do this would be to set up proper foreign key relationships along with cascade options in the database. Then you don't have to worry about this at all.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups