1、增加表单数据:
INSERT INTO 表名 (字段1,字段2,字段3) VALUES (值1,值2,值3)
举例:
INSERT INTO user (name,city,sex) VALUES (‘小小‘,‘北京‘,1)
2、查询表单数据:
SELECT * FROM user
举例:
//查询user表中的所有信息 SELECT * FROM user
//查询user表中的 name和city字段
SELECT name,city FROM user
//查询id=4的用户
SELECT name,city FROM user WHERE id=4
//多条件合并查询 and
SELECT name,city FROM user WHERE city=‘北京‘ AND sex=1
//多条件 or
SELECT name,city FROM user WHERE city=‘北京‘ OR sex=1
3、修改表单数据:
UPDATE user SET name=‘小小2‘,city=‘广州‘ WHERE id=6
举例:
//将user表中 id=6 的数据的name改成小小2 city改成广州 UPDATE user SET name=‘小小2‘,city=‘广州‘ WHERE id=6
4、删除表单数据:
DELETE FROM user WHERE id=7
举例:
//删除user表中 id=7的数据 DELETE FROM user WHERE id=7
5、排序:
SELECT * FROM user ORDER BY id DESC
举例:
//根据id 降序排序 desc代表降序 默认是asc升序 SELECT * FROM user ORDER BY id DESC
。