当前位置:网站首页>数据库基础: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
边栏推荐
- Memo - about C # generating barcode for goods
- Write it down once Net travel management background CPU Explosion Analysis
- Basic knowledge and commands of disk
- Depth first search - DFS (burst search)
- 斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
- Li Kou daily question - Day 32 -589 N × Preorder traversal of tree
- C language learning notes: type definition typedef and declaration external CSDN creation punch in
- 540. Single element in ordered array
- R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用n.of.lines参数指定显示的病例数
- Facebook聊单,SaleSmartly有妙招!
猜你喜欢
Find all missing numbers in the array
为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!
Static timing analysis (STA) in ic/fpga design
Vidéos courtes recommandées chaque semaine: méfiez - vous de la confusion entre « phénomène » et « problème »
Halcon图片标定,使得后续图片处理过后变成与模板图片一样
After studying 11 kinds of real-time chat software, I found that they all have these functions
GAMES202作业0-环境搭建过程&解决遇到的问题
Leetcode-128 longest continuous sequence
How to manage 1000 anchors by one person?
主成分计算权重
随机推荐
1. "Create your own NFT collections and publish a Web3 application to show them." what is NFT
Basic concepts of binary tree
关于企业中台规划和 IT 架构微服务转型
Using OpenSSL encryption to rebound shell traffic
Write an open source, convenient and fast database document query and generation tool with WPF
Lumiprobe非荧光炔烃丨EU(5-乙炔基尿苷)
Livedata postvalue will "lose" data
[noip2015] jumping stone
R语言ggplot2可视化:gganimate创建动态柱状图动画(gif)、在动画中沿给定维度逐步显示柱状图、enter_grow函数和enter_fade函数控制运动内插退出(渐变tweening)
Lumiprobe 双功能交联剂丨Sulfo-Cyanine5 双-NHS 酯
主成分计算权重
Principal component calculation weight
Popular science: what does it mean to enter the kernel state?
PCL learning materials
搭建一個通用監控告警平臺,架構上需要有哪些設計
Regular expression
Halcon图片标定,使得后续图片处理过后变成与模板图片一样
Leetcode-128 longest continuous sequence
What designs are needed in the architecture to build a general monitoring and alarm platform
Search 2D matrix 2