语法:
select * from 表1 cross join 表2;
与
select * from 表1,表2;
1.2内连接:inner join(inner是可以省略的)
1.2.1显示内连接:在SQL中显示的调用inner join 关键字
语法:select * from 表1 inner join 表2 on 关联条件;
例如:select * from classes c inner join student s on c.cid = s.cno;
1.2.2隐式内连接:在SQL中没有调用inner join 关键字
语法:select * from 表1,表2 where 关联条件;
例如:SELECT * FROM classes c,student s WHERE c.cid = s.cno;
1.3外连接:outer join(outer是可以省略的)
1.3.1左外连接:
语法:select * from 表1 left outer join 表2 on 关联条件;
例如:SELECT * FROM classes c LEFT OUTER JOIN student s ON c.cid = s.cno;
1.3.2右外连接:
语法:select * from 表1 right outer join 表2 on 关联条件;
例如:select * from classes c right outer join student s on c.cid = s.cno;
```
###2.子查询
```html
一个查询语句条件需要依赖另一个查询语句的结果.
带in的子查询
例如:查询学生生日在91年之后的班级的信息。
select * from classes where cid in (SELECT cno FROM student WHERE birthday > '1991-01-01');
带exists的子查询
例如:查询学生生日大于91年1月1日,如果记录存在,前面的SQL语句就会执行
select * from classes where exists (SELECT cno FROM student WHERE birthday > '1991-01-01');
带any的子查询
例如:SELECT * FROM classes WHERE cid > ANY (SELECT cno FROM student );
带all的子查询
例如:SELECT * FROM classes WHERE cid > ALL (SELECT cno FROM student);