• TestingDocs
TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL INNER JOIN

Overview

In this tutorial, we will learn about MySQL INNER JOIN. A join that identifies combinations of matching rows from two tables is called as an inner join. There are two different types of syntax for inner joins:

  1. Using comma syntax(lists the tables to be joined separated by a comma)
  2. Using the INNER JOIN keyword

Let’s use the tables in the MySQL world database in the following examples.

Comma Join

https://www.testingdocs.com/mysql-comma-joins/

INNER JOIN Keyword

The INNER JOIN replaces the comma separator between the tables. The join row matching condition is now mentioned in the ON sub-clause. The INNER JOIN keyword is equivalent to the JOIN keyword and they can be used interchangeably.

Syntax

The general syntax of the statement is as follows:

SELECT <column_list>
FROM <table1> AS t1 INNER JOIN <table2> AS t2
ON <table_relationship_condition> ;

Example

mysql> SELECT c.Code, c.Name, cl.Language
-> FROM Country AS c INNER JOIN CountryLanguage AS cl
-> ON c.Code = cl.CountryCode
-> AND c.Continent=’North America’;

 

MySQL INNER JOIN Keyword

 

A table reference can be aliased using the AS clause.The clause is <table_name> AS <alias_name>. For example, Country AS c. We can refer the table column names with the table alias. c.Code to refer to the Code column in the Country table.

We can also use the WHERE clause to further narrow down the join query results.

USING()

If the name of the joined column is the same( i.e bearing the exact same name)  in the both the joined tables, we can use the USING() clause instead of ON clause after the table names.

SELECT <column_list>

FROM <table1> AS t1 INNER JOIN <table2> AS t2

USING(<common_column_name>)

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

MySQL /

How to secure your SQL Database: Tips and Tricks

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

‹ MySQL SHOW CREATE VIEW Statement› MySQL OUTER JOIN

Recent Posts

  • How to secure your SQL Database: Tips and Tricks
  • Shaping the Future of Development: Exploring Key Trends in Software Engineering
  • Improving Java Performance with Multithreading
  • Difference between PHP and JavaScript?
  • Bing Conversation Styles
  • ChatGPT Introduction
  • Open Source AI Frameworks
  • Artificial Intelligence Tools
  • Top AI Music Applications
  • Top AI Website Design Tools

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com