CRUD操作数据库
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CRUD操作数据库,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1737字,纯文字阅读大概需要3分钟。
内容图文
![CRUD操作数据库](/upload/InfoBanner/zyjiaocheng/497/3e33c51a3c5d489bbbfa222428d5fee6.jpg)
3.给列指定名称
select code as ‘代号‘,name as ‘姓名‘ from info
4.条件查询
select * from info where code=‘p001‘
select * from info where code=‘p001‘ or nation=‘n001‘ 或关系
select * from info where code=‘p001‘ or nation=‘n001‘ 并且关系
5.模糊查询(经常用到)
select * from car where name like ‘%奥迪%‘ 前面后面有n个字符
select * from car where name like ‘_奥迪%‘ 前面出现一个字符
6.排序查询
默认为主键排序
select * from car order by price 以价格进行排序,默认按升序排序
select * from car order by price desc 按降序排列
select * from car order by price asc 按升序排列
select * from car order by price asc,oil desc 按两列排序
7.去重查询
select brand from car 查询brand列
select distinct brand from car 去重查询
8.分页查询(取几条数据)
select * from car limit 5,5 跳过5条,取5条 (当前页-1)*5
9.统计查询(聚合函数)
数据条数
select count(*) from car 有多少数据
select count(code) from car 只看主键列,可以提高查询效率
取最大值
select max(price) from car 取price列的最大值
最小值
select min(price) from car 取price列的最小值
取平均值
select avg(price) from car 取price的平均值
10.分组查询
根据某一列分组,统计某一组的数量
select brand, count(*) from car group by brand
select brand from car group by brand having count(*)>=3
11.范围查询
select * from car where price>=40 and price<=60
select * from car where price between 40 and 60
12.离散查询
select * from car where price in (10,20,30)
select * from car where price not in(10,20,30)
CRUD操作数据库
标签:tin 列排序 .com count asc info 范围 order 字符
本文系统来源:https://www.cnblogs.com/niushuangmeng/p/8157623.html
内容总结
以上是互联网集市为您收集整理的CRUD操作数据库全部内容,希望文章能够帮你解决CRUD操作数据库所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。