的信息。
方式一(通用型):SELECT ... FROM ... WHERESELECT e.last_name,e.department_id,d.department_nameFROM employees e,departments dwhere e.department_id = d.department_id方式二:SELECT ... FROM ... NATURAL JOIN ...有局限性:会自动连接两个表中相同的列(可能有多个:department_id和manager_id)SELECT last_name,department_id,department_nameFROM employeesNATURAL JOIN departments方式三:SELECT ... JOIN ... USING ...有局限性:好于方式二,但若多表的连接列列名不同,此法不合适SELECT last_name,department_id,department_nameFROM employeesJOIN departmentsUSING(department_id)方式四:SELECT ... FROM ... JOIN ... ON ...常用方式,较方式一,更易实现外联接(左、右、满)SELECT last_name,e.department_id,department_nameFROM employees eJOIN departments dON e.department_id = d.department_id--内连接 1) --等值连接 --不等值连接 2) --非自连接 --自连接--外连接 --左外连接、右外连接、满外连接新闻热点
疑难解答