1.查询语句
SELECT * FROM table
2.更改语句
UPDATE table SET name = '123456' WHERE id = 100
3.插入语句
INSERT INTO table VALUES(1,'0001','2009-01-01 00:00:02','192.168.1.1',2,NULL,NULL)
4.删除语句
DELETE FROM zhw_dl WHERE id = 5
5.查找指定范围时间的数据
SELECT * FROM table WHERE timer BETWEEN '2017-06-01 00:00:00' AND '2017-06-01 23:59:59'
6.in-操作符
SELECT * FROM table WHERE id IN ('1','2')
7.MAX-操作符(取最大值)?&&MIN(取最小值)
SELECT MAX(id) FROM table
8.添加索引
ALTER TABLE 表名字 ADD INDEX 索引名字 ( 字段名字 )
主键索引:ALTER TABLE 表名字 ADD PRIMARY KEY (字段名字)
唯一索引:ALTER TABLE 表名字 ADD UNIQUE (字段名字)
9.将两个表中的指定数据插入到另一表中
INSERT INTO bbs_collect(userid,uid,hid,t) SELECT bbs_userid AS userid,u.id AS uid,h.id AS hid,'2017-06-13 17:57:19' AS t FROM bbs_user u,bbs_hao h WHERE u.jkx_userid = 'manasxx' AND h.zt IN (1,2)
10.多表查询
SELECT s.*,sf.field1 AS nickname FROM pre_home_friend s,pre_common_member_profile sf WHERE s.uid=17 AND sf.uid=s.fuid LIMIT 24