Auto commit
This commit is contained in:
parent
470ff460d9
commit
124501634a
@ -27,5 +27,31 @@ REFERENCES 表名(字段) 字段是表中的主键
|
||||
ALTER TABLE 表名 ADD CONSTRAINT 外键名 FOREIGN KEY(字段名) REFERENCES 表名(主键字段名);
|
||||
ALTER TABLE t_employee ADD CONSTRAINT fK_did FOREIGN KEY(did) REFERENCES t_department(did);
|
||||
|
||||
#4 排序、分页查询
|
||||
/*
|
||||
基础查询
|
||||
SELECT 字段
|
||||
FROM 表
|
||||
ORDER BY 需要排序的字段 ASC/DESC(升序/降序)
|
||||
LIMIT 起始位置,个数;
|
||||
*/
|
||||
#查询出员工的所有信息
|
||||
SELECT *
|
||||
FROM t_employee;
|
||||
#在基础查询之上对年龄进行降序排序
|
||||
SELECT *
|
||||
FROM t_employee
|
||||
ORDER BY age DESC;
|
||||
#在排序的基础之上,进行分页
|
||||
SELECT *
|
||||
FROM t_employee
|
||||
ORDER BY age DESC
|
||||
LIMIT 5, 8;#第0个代表第一个 第六个使用的位置是5
|
||||
|
||||
|
||||
#5
|
||||
|
||||
#6
|
||||
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user