Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8341901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:37:10+00:00 2026-06-09T05:37:10+00:00

I have 2 tables: A and B A contains the following columns: Id [uniqueIdentifier]

  • 0

I have 2 tables: A and B

A contains the following columns:

Id [uniqueIdentifier] -PK
checkpointId [numeric(20,0)]

B contains the following:

Id [uniqueIdentifier] – PK
A_id (FK, uniqueIdentifier)

B has a reference to A from A_id column (FK)

The question:
I want to delete all records from table A that their checkpoint_id is less than X:

delete from CheckpointStorageObject where checkpointIdentifierIdentifier <= 1000

But I can’t do it since "The primary key value cannot be deleted because references to this key still exist"

I tried to delete first from B table without a join:

DELETE FROM CheckpointToProtectionGroup 
WHERE EXIST (SELECT * from CheckpointStorageObject 
             WHERE CheckpointStorageObject.CheckpointIdentifierIdentifier <= 1000)

But it didn’t work.

How can I do it?
Is it possible to delete from both table with one execute commands?

The resulted deleted records may be very big – more than 30K records in each table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:37:12+00:00Added an answer on June 9, 2026 at 5:37 am

    Try this:

    First delete from tableB:

    delete from tableB where A_id IN (Select Id from tableA where checkpointId <= 1000)
    

    And then delete from tableA:

    delete from tableA where checkpointId <= 1000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following tables: PartyRelationship EffectiveDatedAttributes PartyRelationship contains a varchar column
i have four tables user-question contains two columns: questionID, userID, the questions that the
I have two tables say Table1 and Table2 that contains the following column with
I have a table that contains the following columns: ID int, DISTANCE float, EVENT
I have a table of surveys which contains (amongst others) the following columns survey_id
I have the following requirement. I have a table with a column that contains
I have a database with two tables, tblPlayers and tblMatches. tblPlayers contains the following
I have 2 tables (Document and DocumentClass) that have the following columns: DocumentClass: DocClassID,
I have two tables, both with the same columns. The first table contains original
In one of my MySQL tables, I have following columns: Skills varchar(80) Industry varchar(40)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.