UPDATE
修改
update user set age=28 where id=1;
一定要有表达式,否则严重错误
DELETE
删除
delete from user where id=1; 指定删除某一行
delete from user; 表里内容彻底请客
truncate table user; 处理大量数据效率高,用时更少
SELECT
加载数据
wget 'https://codeload.github.com/datacharmer/test_db/zip/master' -O master.zip
执行导入
mysql -u root -p <employees.sql
加载成功之后,可以查看到具体的数据库的信息
MySQL查询
基本查询数据
全表查询
select * from user;
查询部分字段
select name from user; 查询表内名字
计数
select count(*) from user; 查询表内有多少数据
select count(1) from user; 查询表内多少数据(效率更高一些,适用于数据量较大的)
条件过滤
并且(AND)
select * from user where name="ghj" and age=18;
或者(OR)
select * from user where name="ghj" or age=20;
包含(IN)
select * from user where name in ("ghj","lisi");
范围检查(BETWEEN AND)
select * from user where age between 18 and 20;
否定结果(NOT)
select * from user where name not in ("ghj","lisi");
select * from user where age not between 18 and 20;
匹配任意字符(%)
select * from user where name like 'g%';
以什么为开头(^)
select * from user where name rlike '^g';
以什么为结束($)
select * from user where user rlike 'si$';
使用别名(AS)
select count(1) as count from user;
搜索
复制
标签:name,age,查询,user,MySQL,where,select From: https://www.cnblogs.com/Aurora--1/p/16620788.html