当前位置:网站首页>数据库基础: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
边栏推荐
- How to manage 1000 anchors by one person?
- What if the reliability coefficient is low? How to calculate the reliability coefficient?
- Qt中的QFile读写文件操作
- R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用n.of.lines参数指定显示的病例数
- Blue Bridge Cup real topic: the shortest circuit
- Lumiprobe Lumizol RNA 提取试剂解决方案
- Implementation of converting PCM file to WAV
- Basic concepts of binary tree
- Roll out! Enlightenment!
- Lumiprobe非荧光炔烃丨EU(5-乙炔基尿苷)
猜你喜欢
Navicat premium 15 permanent cracking and 2021 latest idea cracking (valid for personal testing)
每周推荐短视频:警惕“现象”与“问题”相互混淆
PCL learning materials
用GSConv+Slim Neck改进Yolov5,将性能提升到极致!
Must see, time series analysis
Depth first search - DFS (burst search)
创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
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
Basic concepts of binary tree
磁盘的基本知识和基本命令
随机推荐
R language epidisplay package ordinal or. The display function obtains the summary statistical information of the ordered logistic regression model (the odds ratio and its confidence interval correspo
因子分析怎么计算权重?
Facebook聊单,SaleSmartly有妙招!
Computer network interview assault
Qt中的QFile读写文件操作
Lumiprobe non fluorescent alkyne EU (5-ethynyluridine)
Leetcode-83 delete duplicate elements in the sorting linked list
Using OpenSSL encryption to rebound shell traffic
磁盘的基本知识和基本命令
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
OpenAI|视频预训练 (VPT):基于观看未标记的在线视频的行动学习
Sanfeng cloud 0215 I often use
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
Leetcode-128 longest continuous sequence
NSI packaging script add file details
Write an open source, convenient and fast database document query and generation tool with WPF
R语言使用epiDisplay包的tableStack函数制作统计汇总表格(基于目标变量分组的描述性统计、假设检验等)、不设置by参数则计算数据框指定数据列范围的基础描述性统计信息
Find all missing numbers in the array
R语言ggplot2可视化:gganimate包transition_time函数创建动态散点图动画(gif)、shadow_wake函数配置动画的渐变效果(gradual falloff)拖尾效应
Vidéos courtes recommandées chaque semaine: méfiez - vous de la confusion entre « phénomène » et « problème »