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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:18:56+00:00 2026-05-26T17:18:56+00:00

I want to do what seems like a simple delete in mysql but am

  • 0

I want to do what seems like a simple delete in mysql but am having some trouble. I want to do this:

delete from table where col_name not in (select distinct col_name from table);

This table does not have a unique key. When I try this, I get the error:

You can’t specify target table for update in from clause; ErrorNr. 1093

mysql community 5.1

Is there a way i can save the output from this query ->

select distinct col_name from table;

into temp. table and use it in the delete query?

  • 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-26T17:18:56+00:00Added an answer on May 26, 2026 at 5:18 pm

    You must use an alias.

    delete from table where col_name not in (select a.col_name from (select distinct col_name from table) a);
    

    It should work.

    Edit : sorry, I misunderstood the question, and only focus on the SQL Error. The probleme to delete duplicate line with no unique key isn’t answered by the above request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seems like this should be super-simple but looking around for a simple (or half-way
This seems like the most common relationship but for some reason I cannot get
I want to do something like this, but the this keyword doesn't seem to
I want to order by Time,but seems no way to do that ? mysql>
This seems like it should have a super easy solution, but I just can't
Executor seems like a clean abstraction. When would you want to use Thread directly
Seriously, it seems like every time I want to make my UI elements talk
I want to cach input, which seems to be like SQL injection. I know
Microsoft seems to want us to stop using the MDI, but if more people
I'm getting some very wierd errors. The compiler seems to want to call the

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.