Breaking News

Script for database (Select two table use Inner Join, Right Join, Left Join, and Full Join)

Example of database table :
The table name is Names


CodeName
A01Leo
A02Aries
A03Taurus
A04Gemini

Example of database table :
The table name is Values

CodeValue
A0190
A02100
A0395

Inner join

Inner join  for display record where both correct
SELECT Table_name.Field_name, Table_name.Field_name, .......
FROM Table_name, Table_name
WHERE Condition
Example:
SELECT Names.Code, Names.Name, Values.Value
FROM Names, Values
WHERE Names.Code = Values.Code
The display is
CodeNamesValue
A01Leo90
A02Aries100
A03Taurus95


Right join

Right join  for display record by the right table
SELECT Table_name.Field_name, Table_name.Field_name, .......
FROM Table_name
RIGHT JOIN Table_name
WHERE Condition
Example:
SELECT Names.Code, Names.Name, Values.Value
FROM Names
RIGHT JOIN Values
WHERE Names.Code = Values.Code
The display is
CodeNamesValue
A01Leo90
A02Aries100
A03Taurus95

 

Left join

Left join  for display records by the left  table
SELECT Table_name.Field_name, Table_name.Field_name, .......
FROM Table_name
LEFT JOIN Table_name
WHERE Condition
Example:
SELECT Names.Code, Names.Name, Values.Value
FROM Names
LEFT JOIN Values
WHERE Names.Code = Values.Code
The display is
CodeNamesValue
A01Leo90
A02Aries100
A03Taurus95
A04Gemini
 

Full join

Full join  for display all records in tables
SELECT Table_name.Field_name, Table_name.Field_name, .......
FROM Table_name
FULL JOIN Table_name
WHERE Condition
Example:
SELECT Names.Code, Names.Name, Values.Value
FROM Names
FULL JOIN Values
WHERE Names.Code = Values.Code
The display is
CodeNamesValue
A01Leo90
A02Aries100
A03Taurus95
A04Gemini
 

No comments