[Mysql 查询语句]——查询指定记录
#比较
等于
select * from orders where order_num = 2006;
大于
select * from orders where order_num > 2006;
小于
select * from orders where cust_id < 10003;
小于或等于
select * from orders where cust_id <= 10003;
大于或等于
select * from orders where cust_id >= 10003;
不等于
select * from orders where cust_id != 10003;
排除掉
select * from orders where cust_id <> 10003;
#指定范围查询 BETWEEN IN
select cust_id from orders where cust_id between 10004 and 10005;
select cust_id from orders where cust_id not between 10004 and 10005;
#指定集合查询 IN
select cust_id from orders where cust_id in (10003,10004);
select cust_id from orders where cust_id not in(10003,10004);
集合元素可以是字符串类型
select * from student where name in ('taeyeon','jessica');
#匹配字符查询 LIKE
like中可以使用通配符(%)和(_)
%表示匹配0个或多个字符
_表示匹配1个字符
select * from employee where name like "Jelly";
select * from employee where name not like "Jelly";
select * from employee where name like "J%y";
select * from employee where name like "K_y";
select * from employee where homeaddr like "北京%";
#查询空值
select * from vendors where vend_state is null;
select * from vendors where vend_state is not null;
#带AND|OR的多条件查询
select * from employee WHERE age=26 AND sex like '男';
select * from employee WHERE age=26 OR sex like '男';
select * from employee WHERE id<1005 AND age<26 AND sex='男';
select * from employee WHERE id IN (1001,1005) AND age BETWEEN 20 and 26;
[Mysql 查询语句]——查询指定记录的更多相关文章
- 2-14-1 MySQL基础语句,查询语句
一. SQL概述 结构化查询语言(Structured Query Language)简称SQL 1. 它是一种特殊目的的编程语言 2. 它还是一种数据库查询和程序设计语言 (用于存取数据以及查询.更 ...
- [Mysql 查询语句]——查询字段
查询所有字段 select * from 表名; 可以用 * 号代表所有字段 select * from vendors; +---------+----------------+--- ...
- sql查询语句查询顺序
一 SELECT语句关键字的定义顺序 SELECT DISTINCT <select_list> FROM <left_table> <join_type> JOI ...
- [mysql]当mysql查询语句查询的结果为空时,返回query结果是什么类型的呢?
php > $con = mysql_connect('localhost' , 'hnb' , 'alyHnb2015'); php > print_r($con);Resource i ...
- Mysql IN语句查询
语法: WHERE column IN (value1,value2,...) WHERE column NOT IN (value1,value2,...) 1.in 后面是记录集,如: selec ...
- mysql select语句查询流程是怎么样的
select查询流程是怎么样的 mysql select查询的数据是查询内存里面,如果没有查询的数据没有在内存,就需要mysql的innodb引擎读取磁盘,将数据加载的内存后在读取.这就体现了,mys ...
- mysql查询语句 查询方式
- sqlserver 把两个sql查询语句查询出来的两张表合并成一张表
第一个sql语句 select companyname gsmc,zb zhibiao from t_gsndzb left join t_companycode on t_gsndzb.gsbh=t ...
- oracle查询语句查询增加一列内容
select a,sys_guid() as b from mytable sys_guid() 是生成带分隔符(-)的GUID的自定义函数 查询B表的内容插入A表,MY_ID是A表的主键不可为空,因 ...
随机推荐
- Jenkins RestAPI调用出现Error 403 No valid crumb was included in the request
方法一(不推荐): 在jenkins 的Configure Global Security下 , 取消“防止跨站点请求伪造(Prevent Cross Site Request Forgery exp ...
- raiserror 的用法
if exists(select top 1 UserName from [dbo].[LJS_Test_User] where UserName=@UserName) begin raiserror ...
- 其他信息: 实体类型 xxxxx 不是当前上下文的模型的一部分。
我是手动添加的EF类的, 解决方法: 没有在DbContext 添加 public virtual DbSet<xxx> xxxx{ get; set; } 导致不在上下文中
- UWP开发入门(三)——{x:Bind}扩展标记
上周打炉石打得太晚……忘记更新了,本周补上.本篇我们讲一下{x:Bind}扩展标记.{x:Bind}扩展标记也是Windows 10 Uinversal 新增的内容,按官方的说法是 {Binding} ...
- 基于SSH的客户关系管理系统CRM-JavaWeb项目-有源码
开发工具:Myeclipse/Eclipse + MySQL + Tomcat 项目简介: 项目的编译和运行:1 将数据库导入MysSql里 :打开HeidiSql这个图形化工具,新建一个数据库, 可 ...
- “全栈2019”Java异常第二十章:自定义异常详解
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java异 ...
- oracle根据四位年周取当周周一的日期函数
create or replace function FUNC_GET_DATE_BY_WEEK( theYearWeek IN VARCHAR2)return date is normalDate ...
- 【BZOJ2440】[中山市选2011]完全平方数
题意描述 原题 一句话描述: 求第K个不是完全平方数的倍数的数. K≤$10^{9}$ ------------------------------------------ 题解: 首先,直接求第$k ...
- P4211[BZOJ 3626] [LNOI2014]LCA
题目描述 给出一个n个节点的有根树(编号为0到n-1,根节点为0).一个点的深度定义为这个节点到根的距离+1. 设dep[i]表示点i的深度,LCA(i,j)表示i与j的最近公共祖先. 有q次询问,每 ...
- Struts2、SpringMVC、Servlet(Jsp)性能对比 测试
Struts2.SpringMVC.Servlet(Jsp)性能对比 测试 . Servlet的性能应该是最好的,可以做为参考基准,其它测试都要向它看齐,参照它. 做为一个程序员,对于各个框架的性能要 ...