当前位置:网站首页>数据库基础: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
边栏推荐
- The ultimate version of the 13th simulation of the single chip microcomputer provincial competition of the Blue Bridge Cup
- R language ggplot2 visualization: gganimate package transition_ Time function to create dynamic scatter animation (GIF), shadow_ The wake function configures the gradient falloff tailing effect of the
- 如何运营好技术相关的自媒体?
- 实现一个Prometheus exporter
- 6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷
- Find all missing numbers in the array
- Leetcode-160相交链表
- 2、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》启动并运行您的本地环境
- Three.js学习-相机Camera的基本操作(了解向)
- Operation of cmake under win
猜你喜欢

Memo - about C # generating barcode

力扣每日一题-第32天-589.N×树的前序遍历

Operation of cmake under win

Localization through custom services in the shuttle application

Depth first search - DFS (burst search)

MySQL connection tools

关于企业中台规划和 IT 架构微服务转型

Lumiprobe Lumizol RNA 提取试剂解决方案

Three. JS learning - basic operation of camera (learn from)

为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!
随机推荐
Sanfeng cloud 0215 I often use
Blue Bridge Cup real problem: word analysis
6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷
记一次 .NET 差旅管理后台 CPU 爆高分析
Li Kou daily question - Day 32 -589 N × Preorder traversal of tree
How does factor analysis calculate weights?
golang 错误处理
[acnoi2022] color ball
Lumiprobe bifunctional crosslinker sulfo cyanine 5 bis NHS ester
Basic knowledge and commands of disk
Leetcode-83 删除排序链表中重复的元素
Xia CaoJun ffmpeg 4.3 audio and video foundation to engineering application
Popular science: what does it mean to enter the kernel state?
Evaluation of 6 red, yellow and black list cameras: who is the safest? Who has good picture quality? From now on, let you no longer step on thunder
How to change guns for 2D characters
搭建一个通用监控告警平台,架构上需要有哪些设计
力扣每日一题-第32天-1232. 缀点成线
解决方案:可以ping别人,但是别人不能ping我
ACM MM 2022视频理解挑战赛视频分类赛道冠军AutoX团队技术分享
R语言使用dplyr包的transmute函数计算dataframe数据中的指定数据列的移动窗口均值、使用ggplot2包可视化移动均值与原始数据的折线图