当前位置:网站首页>数据库基础:select基本查询语句
数据库基础:select基本查询语句
2022-07-01 18:35:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
数据库基本查询语句规范为:select 区域 from 表名
查询指定表
select * from 表名
*:代表所有列
示例:select * from TL_REQUEST
查询指定列
select 列名 from 表名
列名:代表从指定的列名中查找
,:如果是查找对应的多列,则用英文逗号间隔
示例: select BU_NO from TL_REQUEST select BU_NO,BU_NM from TL_REQUEST
条件查询
select * from 表名 where 条件
*:代表所有列
条件:一般都是where加条件表达式
查询列里包含数字或字母:select * from 表名 where 列名=’值’
示例: select * from TL_REQUEST where BU_NO=’1234′ select * from TL_REQUEST where BU_NM=’小芳’
范围查询
select * from 表名 where 列名 between ‘A’ and ‘B’
或
select * from 表名 where 列名>=’A’ and 列名<=’B’
示例: select*from TL_REQUEST where BU_NO between ‘1000’ and ‘1234’ select*from TL_REQUEST where BU_NO>=’1000′ and BU_NO<=’1234′
多条件查询
或条件查询:or
select * from 表名 where 列名=’A’ or列名=’B’
示例:select * from TL_REQUEST where BU_NO=’1000′ or BU_NO=’1234′
和条件查询:and
select * from 表名 where 列名=’A’and列名=’B’
示例:select * from TL_REQUEST where BU_NO=’1000′ and CONTRACT_NO=’tl001′
离散查询
包含值查询:in()
select * from 表名 where 列名=’A’ 列名=’B’列名=’C’
或:
select * from 表名 where 列名 in(‘A’,’B’,’C’)
示例: select * from TL_REQUEST where BU_NO=’1000′ BU_NO=’1234′ BU_NO=’1311′ 或: select * from TL_REQUEST where BU_NO in(‘1000′,’1234′,’1311’)
不包含值查询:not in()
select * from 表名 where 列名 not in(‘A’,’B’,’C’)
示例:select * from TL_REQUEST where BU_NO not in(‘1000′,’1234′,’1311’)
模糊查询
查询列里包含具体中文:select * from 表名 where 列名like ‘%中文%’
Like:名称前面加。
%:任意多个字符。
_:下划线表示任意一个字符。
示例:select * from TL_REQUEST where BU_NM like ‘%杜芳%’ 或查询第二个字符为芳的情况 select * from TL_REQUEST where BU_NM like ‘%_芳%’
去重查询
select distinct 列名 from 表名
示例:select distinct BU_NO from TL_REQUEST
组合查询
select distinct 列名 from 表名 where 条件
示例:select distinct BU_NO from TL_REQUEST where BU_NO between ‘1000’ and ‘1234’
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/130835.html原文链接:https://javaforall.cn
边栏推荐
- Popular science: what does it mean to enter the kernel state?
- 每周推荐短视频:警惕“现象”与“问题”相互混淆
- Localization through custom services in the shuttle application
- Unity learning fourth week
- Sum of three numbers
- Mysql database of easyclick
- Cloud computing - make learning easier
- Memo - about C # generating barcode
- 每周推薦短視頻:警惕“現象”與“問題”相互混淆
- Solution: you can ping others, but others can't ping me
猜你喜欢
用WPF写一款开源方便、快捷的数据库文档查询、生成工具
Leetcode203 remove linked list elements
为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!
Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!
Leetcode-21 combines two ordered linked lists
Leetcode-128 最长连续序列
Leetcode203 移除链表元素
Memo - about C # generating barcode
Lumiprobe lumizol RNA extraction reagent solution
12 data dimensioning processing methods
随机推荐
OpenAI|视频预训练 (VPT):基于观看未标记的在线视频的行动学习
实现一个Prometheus exporter
如何在自有APP内实现小程序实现连麦直播
Is Alipay wallet convenient to use?
Weekly recommended short videos: be alert to the confusion between "phenomena" and "problems"
Basic knowledge and commands of disk
How to manage 1000 anchors by one person?
Calculation of intersection of two line segments
Localization through custom services in the shuttle application
记一次 .NET 差旅管理后台 CPU 爆高分析
[CF559E]Gerald and Path
Relational database management system of easyclick
The R language cartools package divides the data, the scale function scales the data, the KNN function of the class package constructs the k-nearest neighbor classifier, and the table function calcula
Li Kou daily question - Day 32 -589 N × Preorder traversal of tree
用WPF写一款开源方便、快捷的数据库文档查询、生成工具
[Chongqing Guangdong education] basic psychology reference materials of Tianjin Normal University
R language ggplot2 visualization: visualize the line graph and add customized Y-axis label information to the line graph using the labels function
The ultimate version of the 13th simulation of the single chip microcomputer provincial competition of the Blue Bridge Cup
Qt中的QFile读写文件操作
Cloud computing - make learning easier