ddxiami

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3078|回复: 0

[优化案例] MySQL基础之增删改查

[复制链接]
发表于 2014-10-21 19:19:50 | 显示全部楼层 |阅读模式
#配合前面,录入基础数据
INSERT INTO `think_user` VALUES ('1', '黄振国', '1', '32');
INSERT INTO `think_user` VALUES ('2', '张金女', '0', '27');
INSERT INTO `think_user` VALUES ('3', '黄佳敏', '0', '2');
INSERT INTO `think_user` VALUES ('4', '黄美嘉', '0', '7');
INSERT INTO `think_user` VALUES ('5', '黄佳滢', '0', '7');

#查询
select * from think_user where id>2

#插入
insert into think_user(name,sex,age) values('黄振帮',1,35)

#删除
delete from think_user where id>5

#更新
update think_user set age=3 where name='黄佳滢'

#查找
select * from think_user where name like '%佳%'

#排序
select * from think_user order by age desc

#总数
select count(*) as totalcount from think_user

#求和
select sum(age) as sumvalue from think_user

#平均
select avg(age) as avgvalue from think_user

#最大
select max(age) as maxval from think_user

#最小
select min(age) as minval from think_user





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|技术文档库 ( 闽ICP备15017263号-2 )|网站地图

GMT+8, 2025-5-18 23:29 , Processed in 0.034838 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表