多表查询语法:
SELECT table1.column, table2.column
FROM table1, table2
WHERE table1.column1 = table2.column2;
但要注意where 不要省,省略where 即为笛卡尔集,而且where 条件要有效,两张表间有一个相同的字段,才好进行有效的多表查询
内连接:
select empno,ename,sal,dname,loc from emp,dept
where emp.deptno=dept.deptno;
内连接的另一种写法:
select empno,ename,job,sal,dept.deptno,dname,loc
from emp join dept on (emp.deptno=dept.deptno);
外连接语法:
SELECT table1.column, table2.column --右外连接
FROM table1, table2
WHERE table1.column(+) = table2.column;
SELECT table1.column, table2.column --左外连接
FROM table1, table2
WHERE table1.column = table2.column(+);
select empno,ename,job,sal,dept.deptno,dname,loc
from emp,dept
where emp.deptno(+)=dept.deptno;
未完。。。