The INNER JOIN keyword return rows when there is at least one match in both tables.
SELECT column_name
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
The "Pur" table
The "Purdet" table
Example :
SELECT PurDet.OrderNo,Pur.custname, Pur.City
FROM Pur
INNER JOIN PurDet
ON Pur.Orderno=PurDet.OrderNo
ORDER BY Pur.CustName
Output :
SELECT column_name
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
The "Pur" table
OrderNo
|
Custname
|
City
|
1
|
Siva
|
Srivilliputtur
|
2
|
Bala
|
Sivakasi
|
3
|
Kanna
|
Madurai
|
The "Purdet" table
Sno
|
OrderNo
|
Qty
|
Rate
|
1
|
2
|
50
|
70
|
2
|
2
|
30
|
56
|
3
|
1
|
100
|
200
|
4
|
5
|
30
|
30
|
5
|
4
|
60
|
80
|
Example :
SELECT PurDet.OrderNo,Pur.custname, Pur.City
FROM Pur
INNER JOIN PurDet
ON Pur.Orderno=PurDet.OrderNo
ORDER BY Pur.CustName
Output :
OrderNo
|
custname
|
city
|
2
|
Bala
|
Sivakasi
|
2
|
Bala
|
Sivakasi
|
1
|
Siva
|
Srivilliputtur
|
No comments:
Post a Comment