mysql multi-table queries equi table aliased

Case #: Query goddess name and the name of god

SELECT 
    NAME,boyName
FROM
    boys,beauty
WHERE
    beauty.boyfriend_id=boys.id;

USE myemployees;

Case #: department employee name query the employees table names and corresponding departments table, define the same field names

SELECT
    last_name,department_name
FROM
    departments,employees
WHERE
    employees.department_id=departments.department_id;

Case #: Query employees name, type of work number, type of work were defined field names and field names the same query

SELECT
    last_name,employees.job_id,job_title
FROM
    employees,jobs
WHERE
    employees.job_id=jobs.job_id;

# Alias ​​table, if taking the alias, the table name can not be used to define the original

SELECT 
    last_name,e.job_id,job_title
FROM
    employees AS e,jobs AS j
WHERE
    e.job_id=j.job_id;

Guess you like

Origin blog.51cto.com/14437184/2437255