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

  • Home
  • SEARCH
  • 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 748775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:21:32+00:00 2026-05-14T14:21:32+00:00

I would like to try using Outer Join to find out duplicates in a

  • 0

I would like to try using Outer Join to find out duplicates in a table:

If a table has Primary Index ID, then the following outer join can find out the duplicate names:

mysql> select * from gifts;
+--------+------------+-----------------+---------------------+
| giftID | name       | filename        | effectiveTime       |
+--------+------------+-----------------+---------------------+
|      2 | teddy bear | bear.jpg        | 2010-04-24 04:36:03 |
|      3 | coffee     | coffee123.jpg   | 2010-04-24 05:10:43 |
|      6 | beer       | beer_glass.png  | 2010-04-24 05:18:12 |
|     10 | heart      | heart_shape.jpg | 2010-04-24 05:11:29 |
|     11 | ice tea    | icetea.jpg      | 2010-04-24 05:19:53 |
|     12 | cash       | cash.png        | 2010-04-24 05:27:44 |
|     13 | chocolate  | choco.jpg       | 2010-04-25 04:04:31 |
|     14 | coffee     | latte.jpg       | 2010-04-27 05:49:52 |
|     15 | coffee     | espresso.jpg    | 2010-04-27 06:03:03 |
+--------+------------+-----------------+---------------------+
9 rows in set (0.00 sec)

mysql> select * from gifts g1 LEFT JOIN (select * from gifts group by name) g2 
         on g1.giftID = g2.giftID where g2.giftID IS NULL;
+--------+--------+--------------+---------------------+--------+------+----------+---------------+
| giftID | name   | filename     | effectiveTime       | giftID | name | filename | effectiveTime |
+--------+--------+--------------+---------------------+--------+------+----------+---------------+
|     14 | coffee | latte.jpg    | 2010-04-27 05:49:52 |   NULL | NULL | NULL     | NULL          |
|     15 | coffee | espresso.jpg | 2010-04-27 06:03:03 |   NULL | NULL | NULL     | NULL          |
+--------+--------+--------------+---------------------+--------+------+----------+---------------+
2 rows in set (0.00 sec)

But what if the table doesn’t have a Primary Index ID, then can an outer join still be used to find out duplicates?

P.S. thanks for any non-outer-join solutions as well. If possible, I’d like to check whether it can be done using an outer join when there is no Primary ID index. thanks for helping.

  • 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-14T14:21:32+00:00Added an answer on May 14, 2026 at 2:21 pm

    Use EXISTS clause:

    SELECT  *
    FROM    gifts go
    WHERE   EXISTS
            (
            SELECT  NULL
            FROM    gifts gi
            WHERE   gi.name = go.name
            LIMIT 1, 1
            )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to try out different animation styles for a popup window using
Having successfully tried out nHibernate, I would now like to try using Fluent for
I am usually using table to do layouting. But I would like to try
I would like to try programming genie , but I can't find neither source
I would like to try out Capistrano to deploy a PHP application but can't
I recently found out about Cytoscape.js and would like to try out the force-directed
I just stuck at this and cannot find solution. I would like to try
I would like to try using an DI/IoC framework for the first time in
I would like to restore my database in MySQL. When I try manually using
I've been experimenting with F# and would like to try using it in a

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.