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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:54:24+00:00 2026-06-07T02:54:24+00:00

In a MySQL JOIN , what is the difference between ON and USING() ?

  • 0

In a MySQL JOIN, what is the difference between ON and USING()? As far as I can tell, USING() is just more convenient syntax, whereas ON allows a little more flexibility when the column names are not identical. However, that difference is so minor, you’d think they’d just do away with USING().

Is there more to this than meets the eye? If yes, which should I use in a given situation?

  • 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-06-07T02:54:26+00:00Added an answer on June 7, 2026 at 2:54 am

    It is mostly syntactic sugar, but a couple differences are noteworthy:

    ON is the more general of the two. One can join tables ON a column, a set of columns and even a condition. For example:

    SELECT * FROM world.City JOIN world.Country ON (City.CountryCode = Country.Code) WHERE ...
    

    USING is useful when both tables share a column of the exact same name on which they join. In this case, one may say:

    SELECT ... FROM film JOIN film_actor USING (film_id) WHERE ...
    

    An additional nice treat is that one does not need to fully qualify the joining columns:

    SELECT film.title, film_id -- film_id is not prefixed
    FROM film
    JOIN film_actor USING (film_id)
    WHERE ...
    

    To illustrate, to do the above with ON, we would have to write:

    SELECT film.title, film.film_id -- film.film_id is required here
    FROM film
    JOIN film_actor ON (film.film_id = film_actor.film_id)
    WHERE ...
    

    Notice the film.film_id qualification in the SELECT clause. It would be invalid to just say film_id since that would make for an ambiguity:

    ERROR 1052 (23000): Column ‘film_id’ in field list is ambiguous

    As for select *, the joining column appears in the result set twice with ON while it appears only once with USING:

    mysql> create table t(i int);insert t select 1;create table t2 select*from t;
    Query OK, 0 rows affected (0.11 sec)
    
    Query OK, 1 row affected (0.00 sec)
    Records: 1  Duplicates: 0  Warnings: 0
    
    Query OK, 1 row affected (0.19 sec)
    Records: 1  Duplicates: 0  Warnings: 0
    
    mysql> select*from t join t2 on t.i=t2.i;
    +------+------+
    | i    | i    |
    +------+------+
    |    1 |    1 |
    +------+------+
    1 row in set (0.00 sec)
    
    mysql> select*from t join t2 using(i);
    +------+
    | i    |
    +------+
    |    1 |
    +------+
    1 row in set (0.00 sec)
    
    mysql>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my MySQL what is the difference between using the word JOIN or using:
Is there any difference between MySQL BETWEEN operator and using >= <=? When i
Possible Duplicate: Difference between JOIN and INNER JOIN I have found some legacy SQL
Is there a measurable performance difference between using INT vs. VARCHAR as a primary
I need to join two tables from different MySQL (PHP) connection strings and different
I am learning mysql join queries. To pratice, I decided to make tables for
I try to combine data from 2 tables by a mysql join but I
All, I'm reviewing some basic MySQL JOIN tutorials. Jeff Atwood gives an example on
I am trying to join 3 mysql tables; friends, users, and comments. users: id
this is the mysql query SELECT * FROM users AS up JOIN users AS

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.