[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表的主键不可为空,因 ...
随机推荐
- Visual Studio for mac从入门到放弃1
MAC 第一步:从微软官网下载:https://www.visualstudio.com/vs/visual-studio-mac/ 第二步:安装软件过程出现 It was not possible ...
- Django博客项目思路整理
首先明确一点,我目前学习Django是为了做一个博客,那么以博客为目标进行实践的话,按照Django的MTV模型的顺序来思考的话,要考虑如下几个事情: (Models) 1.在博客里的各种数据模型: ...
- djang系列5.5-- 图书管理系统实例
一.表格设计 E-R图 分析图 models.py from django.db import models # Create your models here. class Author(model ...
- ClamAV资料链接
1.http://wiki.ubuntu.org.cn/index.php?title=ClamAV&variant=zh-cn Ubuntu的wiki下对ClamAV的大致介绍,包括使用. ...
- “全栈2019”Java异常第十五章:异常链详解
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java异 ...
- 转载文章 208 个最常见 Java 面试题全解析
最近正值春招,一直在给公司招聘 Java 程序员,我从 2015 年做 TeamLeader 开始就习惯性地收集平时遇到的 Java 技术问题或周围朋友见过的面试题,经过不断筛选,终于凝练成一套实用的 ...
- 【经典漏洞案例】NSA黑客工具包——Windows 0day验证实验
还记得今年4月中旬,Shadow Brokers(影子经纪人)黑客组织发布出一份震惊世界的机密文档,其中包含了多个Windows 远程漏洞利用工具,此工具集覆盖大量的Windows服务 器,可以被任何 ...
- lucene3.0_IndexSearcher排序
系列汇总: lucene3.0_基础使用及注意事项汇总 IndexSearcher排序 本文主要讲解: 1.IndexSearcher中和排序相关的方法及sort类.SortField类(api级别) ...
- 面向对象之ajax
1.Ajax发送请求的几个步骤 1. 创建 XMLHttpRequest 对象 var xhr = new XMLHttpRequest();//IE6 使用var xhr= new ActiveXO ...
- 给 console 添加颜色
简评:使用 %c 声明可以给 console 的输出添加 CSS 样式,日志太多的话,给不同种类的日志设置不同的样式,可以极大的提升阅读体验. 什么是 %c %c: 标识将 CSS 样式应用于 %c ...