Mysql 增删改查基本操作。
- #插入记录
- INSERT INTO person_info(`name`,`country`,`salary`)
- VALUES
- ('小陈','China','10000.20'),
- ('小王','USA','8888.88'),
- ('小张','UK','778.88'),
- ('小花','Canada','666.66');
- #查询记录
- SELECT * FROM person_info;
- #删除
- DELETE FROM person_info WHERE persion_id = 4;
- #更新
- UPDATE person_info SET country = 'UK' WHERE persion_id = 3;
- #带条件查找
- SELECT * FROM person_info WHERE name LIKE '%陈%';
- #排序
- SELECT * FROM person_info ORDER BY persion_id DESC;
- #总数
- SELECT COUNT(*) AS totalcount FROM person_info;
- #求和
- SELECT SUM(salary) AS sumsalary FROM person_info;
- #平均
- SELECT AVG(salary) AS avgsalary FROM person_info;
- #最大
- SELECT MAX(salary) AS maxsalary FROM person_info;
- #最小
- SELECT MIN(salary) AS minsalary FROM person_info;
评论