mysql(3) 查询
来源:互联网 发布:php print r 编辑:程序博客网 时间:2024/06/08 01:58
CURD占到数据库操作的80%
查询占到CURD的80%
查询时,列是变量,变量是可以计算的,where是表达式,查询时判断真假。
select uid from tp_user where 1; 1一直是真,所以会查找出整张表中的uid
select uid from tp_user where 0; 0是假,所以提示empty set.
select uid*2 from tp_user;
select username from tp_user;投影运算,即取出某一列或某几列
select uid,sex,uid-sex from tp_user;广义投影,列之间参与运算
select username from tp_user where uid != 2; 不等于
>2;
<=2;
uid in (4,11);或者uid=4,或者uid=11
uid =4 or uid=11;
uid=4 || uid=11;
uid between 4 and 11;在4~11之间
uid >=4 and uid <=11;
uid >=4 && uid <=11;
not ! 逻辑非
or || 逻辑或
and && 逻辑与
and 的优先级高于or 要用括号提高优先级
like 模糊查询
% 通配任意字符
_ 通配单一字符
where goods_name like ‘诺基亚%’; 查找诺基亚开头的
where goods_name like '诺基亚___'; 查找诺基亚开头的后面跟3个字符的东西
ps:查出来的是乱码:告诉服务器你是什么编码 set names gbk;
把uid是20-30之间的值设为20
update tp_user set age=floor(age/10)*10 where age between 20 and 30;
- mysql(3) 查询
- mysql查询
- Mysql查询
- mysql查询
- MySQL查询
- MySql查询
- mysql查询
- MySQL查询
- [MySQL]查询
- mysql查询
- MYSQL查询
- MySQL查询
- mysql查询
- Mysql查询
- Mysql 查询
- MySQL查询
- MySQL查询
- mysql查询
- Sicily 1945. Monkeys & Bananas
- linux mysql 安装与主从复制
- NYOJ 奇怪的排序 540
- 重载于多态
- NYOJ 113--字符串替换【string】
- mysql(3) 查询
- 清理SYSAUX表空间的WRH$_LATCH_CHILDREN表
- LeetCode: Search for a Range
- ZeroMQ安装及使用
- C语言的那些秘密之---函数返回局部变量
- Leetcode:Unique Binary Search Trees
- VS 和 VAssistX 常用快捷键
- iOS UICollectionView 入门 02 构建松木板
- 数据结构中的树