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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:17:17+00:00 2026-05-11T22:17:17+00:00

I have a table set up as follows id origin destination carrier_id so typical

  • 0

I have a table set up as follows

id
origin
destination
carrier_id

so typical row could be,

100: London    Manchester  366

Now each route goes both ways, so there shouldn’t be a row like this

233: Manchester    London    366

since that’s essentially the same route (for my purposes anyway)

Unfortunately though, i have wound up with a handful of duplicates. I have over 50,000 routes made up of around 2000 point of origin (or destination, however you want to look at it) in the table. So i’m thinking looping through each point of origin to find duplicates would be insane.

So I don’t even know where to start trying to figure out a query to identify them. Any ideas?

  • 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-11T22:17:18+00:00Added an answer on May 11, 2026 at 10:17 pm

    I think you just need a double join, the following will identify all the “duplicate” records joined together.

    Here’s an example.

    Say SELECT * FROM FLIGHTS yielded:

    id  origin   destination  carrierid
    1   toronto  quebec      1
    2   quebec   toronto     2
    3   edmonton calgary     3
    4   calgary  edmonton    4
    5   hull     vancouver   5
    6   vancouveredmonton    6
    7   edmonton toronto     7
    9   edmonton quebec      8
    10   toronto  edmonton  9
    11   quebec   edmonton  10
    12   calgary  lethbridge 11
    

    So there’s a bunch of duplicates (4 of the routes are duplicates of some other route).

    select  *
    from    flights t1 inner join flights t2 on t1.origin = t2.destination 
            AND t2.origin = t1.destination
    

    would yield just the duplicates:

    id  origin   destination carrierid  id  origin  destination carrierid
    1   toronto quebec       1  2   quebec  toronto 2
    2   quebec  toronto      2  1   toronto quebec  1
    3   edmonton    calgary 3   4   calgary edmonton    4
    4   calgary edmonton    4   3   edmonton    calgary 3
    7   edmonton    toronto 7   10  toronto edmonton    9
    9   edmonton    quebec  8   11  quebec  edmonton    10
    10  toronto edmonton    9   7   edmonton    toronto 7
    11  quebec  edmonton    10  9   edmonton    quebec  8
    

    At that point you just might delete all the ones that occurred 1st.

    delete from flights
    where id in (
        select  t1.id
        from    flights t1 inner join flights t2 on t1.origin = t2.destination 
                AND t2.origin = t1.destination
    )
    

    Good luck!

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

Sidebar

Related Questions

We have a table set up as follows: |ID|EmployeeID|Date |Category |Hours| |1 |1 |1/1/2010
I have a table, Messages, which is set out as follows: This table stores
I have a table set up to hold folders. Each folder has an ID
I have a mysql table field set as time type which stores data in
I have a table with white-space set to nowrap and columns widths restricted using
I have a table that displays a set of data. But when I try
I have a table that containts a set of columns one of it is
I have a MySQL database where the table was set up to store the
I have a table with a field: 'last_modified - timestamp NOT NULL' I set
I have a table as follows <table id=vainTbl6 class=dtable cellpadding=3 cellspacing=1 border=0> <thead> <tr><th>check</td><th>Morphosal</th><th>goat

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.