这里记录下常用的 sql 查询语句, 方便必要时使用
增加
INSERT INTO 表名称 VALUES (值1, 值2,....)
INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....)
1
2
3
4
5
2
3
4
5
删除
delete from t1 where xxx = 'xxx'
1
2
3
2
3
修改
update 数据表 set 字段 bai名=字段值 where 条件表 du达式
1
2
3
4
2
3
4
查找
select * from t1;
-- 条件查询
select * from t1 where xxxx='xxx';
-- 模糊查询
select * from Pump p
LEFT JOIN Users u
on p.SysHospital_ID = u.SysHospital_ID
where
u.SysHospital_ID = '666666'
and
u.SysProduct_ID like '%3%'
and
p.SysProduct_ID = '3'
and
u.UserCode = 'floor1'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
清空表
truncate table [表名]
1
2
3
2
3
利用分组查询不重复的数据
select FollowUp from table where FollowUp IS NOT NULL order by max(BillDate) desc;
1