Professional Documents
Culture Documents
Select * From T1(main table) INNER JOIN T2 ON T1.c = T2.c INNER JOIN T3 ON T1.c = T3.c
To show ALL RECORDS of 3 tables
mysql> select * from tbl_employee INNER JOIN tbl_department ON
tbl_employee.dept_code=tbl_department.dept_code INNER JOIN tbl_status ON
tbl_employee.stat_code=tbl_status.stat_code;
To show LNAME, FNAME, DEPT_CODE, STAT, and SALARY in 3 tables// use specific column in a
table to avoid ambiguous error
mysql> select emp_lname,emp_fname,tbl_department.dept_code, stat_desc, stat_salary from
tbl_employee INNER JOIN tbl_department ON tbl_employee.dept_code=tbl_department.dept_code
INNER JOIN tbl_status ON tbl_employee.stat_code=tbl_status.stat_code;
Annual Salary
mysql> SELECT concat(emp_lname,",", emp_fname) AS "Full Name", tbl_employee.dept_code AS
"Department", stat_desc AS "Status", stat_salary AS "Salary" , stat_salary*12 AS "Annual
Salary" from tbl_employee INNER JOIN tbl_department ON tbl_employee.dept_code =
tbl_department.dept_code INNER JOIN tbl_status ON tbl_employee.stat_code =
tbl_status.stat_code ORDER BY "Salary" ASC;
SELECT DISTINCT
SELECT DISTINCT tbl_department.dept_code as department FROM tbl_employee.dept_code=
tbl_department.dept_code;