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 7416137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:25:55+00:00 2026-05-29T07:25:55+00:00

In a previous question I asked how I could sum up a total based

  • 0

In a previous question I asked how I could sum up a total based on some conditions: Count total on couple of conditions

Suppose I have a table like this:

id     col1     col2     col3
1      a        1        k1
2      a        2        k2
3      a        -3       k3
4      b        3        k4

Now, when I get id=1, I want to delete all the rows where col1=a.
When I get id=4, I want to delete all the rows where col1=b.

How would I do this in SQL?

I tried based upon previous answer:

DELETE FROM table WHERE (col1) IN (SELECT col1 FROM table WHERE id = '1')

But that gave me an error: #1093 - You can't specify target table 'table' for update in FROM clause

  • 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-05-29T07:25:58+00:00Added an answer on May 29, 2026 at 7:25 am

    This has been many times on stackowerflow, you cannot UPDATE/DELETE table with data from nested select on the same table. There’re two ways to do this:

    • Load all data before (for example via php, sql procedure)
    • Create temporary table like the one you’re using, clone data and use temporary table to select items
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based off of a previous question I asked, which @Andrie answered, I have a
This is a continuation question from a previous question I have asked I now
This is a related to a previous question I have asked here, see the
This is related to a previous question I asked with Jquery. If I have
This stems from a previous question I asked regarding code metrics. I have been
This is closely related to a previous question i asked. I have a many-to-many
I know that this question might have been asked like 100 times, but, believe
As a followup to the previous question I have asked ASP.Net Architecture Specific to
based my previous question asked here: Jquery Filter List DIVs via checkboxes i got
In a previous question I asked how I could display two different layouts for

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.