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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:13:29+00:00 2026-05-27T11:13:29+00:00

I have multiple queries (from different section of my site) i am executing Some

  • 0

I have multiple queries (from different section of my site) i am executing

Some are like this:

SELECT field, field1 
FROM table1, table2 
WHERE table1.id = table2.id 
AND ....

and some are like this:

SELECT field, field1 
FROM table1 
JOIN table2 
USING (id)  
WHERE ...
AND ....

and some are like this:

SELECT field, field1 
FROM table1 
LEFT JOIN table2 
 ON (table1.id = table2.id)
WHERE ...
AND ....

Which of these queries is better, or slower/faster or more standard?

  • 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-27T11:13:29+00:00Added an answer on May 27, 2026 at 11:13 am

    The first two queries are equivalent; in the MySql world the using keyword is (well, almost – see the documentation but using is part of the Sql2003 spec and there are some differences in NULL values) the same as saying field1.id = field2.id

    You could easily write them as:

    SELECT field1, field2
    FROM table1
    INNER JOIN table2 ON (table1.id = table2.id)
    

    The third query is a LEFT JOIN. This will select all the matching rows in both tables, and will also return all the rows in table1 that have no matches in table2. For these rows, the columns in table2 will be represented by NULL values.

    I like Jeff Atwood’s visual explanation of these

    Now, on to what is better or worse. The answer is, it depends. They are for different things. If there are more rows in table1 than table2, then a left join will return more rows than an inner join. But the performance of the queries will be effected by many factors, like table size, the types of the column, what the database is doing at the same time.

    Your first concern should be to use the query you need to get the data out. You might honestly want to know what rows in table1 have no match in table2; in this case you’d use a LEFT JOIN. Or you might only want rows that match – the INNER JOIN.

    As Krister points out, you can use the EXPLAIN keyword to tell you how the database will execute each kind of query. This is very useful when trying to figure out just why a query is slow, as you can see where the database spends all of its time.

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

Sidebar

Related Questions

I have multiple select statements from different tables on the same database. I was
I have multiple projects in a couple of different workspaces. However, it seems like
I have multiple classes that all derive from a base class, now some of
I have a tricky situation in trying to get information from multiple queries into
I have multiple linq queries that retrieve the same data just at different grouping
I have a sceanrio where i need to retreive values from different sub queries
I have multiple linq queries for searching a database of information based on a
I have multiple selects: <select id=one> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> </select> <select
I want to have multiple scripts running from cron at the same time. They
I'm trying to determine the relative performance of two different queries and have two

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.