Selecting data from multiple tables
In the above query, we queried data of the job_id
column from the employees
table; however, the column values are codes. The actual job description is in the job_title
column in the jobs
table. The following is a pictorial view of the jobs
and employees
tables with a pointer to the join columns:
Let us write a query by joining these two tables on the common column job_id
to fetch information from both the tables. The query is shown as follows:
SELECT e.employee_id, e.first_name, e.last_name, j.job_title FROM employees e, jobs j WHERE e.job_id = j.job_id;