• Teach Your Self With
             w3htmlschool.com

MySQL INNER JOIN clause

MYSQL INNER Joins work on two table where INNER JOIN clause matches rows in one table with rows in second tables and return result contain columns from both tables.
The inner join operation is characterized by the detail that its result contains only rows for which the join condition is satisfied

Syntax


SELECT columns
FROM table1
INNER JOIN table2
ON table1.column = table2.column;
Table
Tables

tablea
name varchar(30) NO NULL
n1 int(11) NO NULL
n2 int(11) NO NULL
color varchar(30) NO NULL
State varchar(30) NO NULL

tableb
s.name varchar(30) NO NULL
n3 int(11) NO NULL
n4 int(11) NO NULL
Example
SELECT name ,n1,n2,n4,n4 from tablea inner join tableb on name = `s.name`;
Output
+------+----+----+----+----+
| name | n1 | n2 | n4 | n4 |
+------+----+----+----+----+
| Tom | 70 | 60 | 70 | 70 |
+------+----+----+----+----+
1 row in set (0.00 sec)