mysql   inner joins

the MySQL inner join clause selects all rows from both tables as long as there is a match between the columns in both tables.

the mysql inner join clause an optional part of the select appears immediately after the from clause.

mysql inner join syntax

                         select    column_name(s)

                         from  table1
                         inner join  table2
                         on   table1.column_name = table2.column_name;


                   select   column_name(s)

                   from   table1         inner join   table2         on    join_condition1
                                              inner join  table3          on    join_condition2
                   where   where_conditions;

theoretically, you can join a table with many tables.

tip :  for better query performance, you should limit the number of tables to join

the following venn diagram illustrates how the mysql inner join clause works.

demo database tables use in inner join example

below is selection from the "user" table:


and selection from the "company" table:

1facebooksocial website
2gmailmailing service
3googlesearch engine

mysql  inner join  example

                select   user.userid, firstname, companyname
                from     user , 
                inner join   company    
                on       user.userid = company.productid;

output :- inner joined table


note : if you join multiple tables that have the same column name, you have to use table qualifier to refer to that column in the select clause to avoid ambiguous column error.

syntax  :    select    table_name.column_name;

Inner join are the most common type of join and also the most smmetrical because they require a match in each table forms a part of the join, rows that do not match are excluded from the final result-set.

the most common example of an inner join is the equi-join, where certain fields in the joined tables are equated to each other.In this case, the final result set only includes those rows from the joined tables that have matches in the specified fields.