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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:51:18+00:00 2026-05-20T11:51:18+00:00

I have a database containing the route data for airlines. Some of the attributes

  • 0

I have a database containing the route data for airlines.
Some of the attributes are sources_airport_ID, destination_airport_ID, and airline(which supports the route from source to destination).
I’m trying to self join the table to look up airlines that have the same route (in other words, same sources_airport_ID and destination_airport_ID).

I was using the query as follows:
(table name = routes)

SELECT t1.*, t2.*
  FROM routes AS t1, routes AS t2
 WHERE t1.sources_airport_ID = t2.sources_airport_ID 
   AND t1.destination_airport_ID = t2.destination_airport_ID 
   AND t1.airline != t2.airline

When I execute this query, I get an error saying that the maximum execution time exceeded 300 seconds. I’m not sure if I’m using the correct query for this purpose.
Can anyone help me with the query? I’m using xampp as my database.

Thanks in advance!

EDIT:
My primary key is ID, which is just an auto-increment value.
There are 64,114 records in routes 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-05-20T11:51:18+00:00Added an answer on May 20, 2026 at 11:51 am

    Try using JOIN syntax:

    SELECT t1.*, t2.*
      FROM routes AS t1
      JOIN routes AS t2
      ON   t1.sources_airport_ID = t2.sources_airport_ID 
      AND  t1.destination_airport_ID = t2.destination_airport_ID 
      AND  t1.airline != t2.airline
    

    But as suggested do make sure that the fields sources_airport_ID, destination_airport_ID and airline are indexed in the routes table.

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

Sidebar

Related Questions

I have data database containing some rather large strings, each of which holds a
I have a database which has records with several fields containing some info. To
I have a MySQL database containing the following tables: Table: Professor Attributes: ID, ProfessorName
it might sound stupid. can we have a database containing some tables without relations.
Suppose we have a simple database containing following data: name apple pear banana grape
I have a ruby on rails 3.0 application which will need a database containing
If I have a database containing only varchar columns, with strings encoded in Latin-1
Say I have at database table containing information about a news article in each
I have a really big database (running on PostgreSQL) containing a lot of tables
I have a ~23000 line SQL dump containing several databases worth of data. I

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.