Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysql multi-table query equivalent join, alias for the table

Shulou Source: shulou.com Published: 2022-06-01 21:44:50 10月02日 Update

# case: query the name of the goddess and the corresponding male name

SELECT NAME,boyNameFROM boys,beautyWHERE beauty.boyfriend_id=boys.id;USE myemployees

# case: the employee name of the query employees table and the department name of the corresponding departments table, and the qualified field name is the same

SELECT last_name,department_nameFROM departments,employeesWHERE employees.department_id=departments.department_id

# case: query employee name, job number, job name, qualified field name is the same as query field name

SELECT last_name,employees.job_id,job_titleFROM employees,jobsWHERE employees.job_id=jobs.job_id

# alias the table. If you choose an alias, you cannot use the original table name to qualify

SELECT last_name,e.job_id,job_titleFROM employees AS e,jobs AS jWHERE e.job_id=j.job_id

Tags: Query field case alias same employee type of work original goddess department divine name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Docker Microsoft Redmi