#比较

等于
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 查询语句]——查询指定记录的更多相关文章

  1. 2-14-1 MySQL基础语句,查询语句

    一. SQL概述 结构化查询语言(Structured Query Language)简称SQL 1. 它是一种特殊目的的编程语言 2. 它还是一种数据库查询和程序设计语言 (用于存取数据以及查询.更 ...

  2. [Mysql 查询语句]——查询字段

    查询所有字段     select  *  from  表名; 可以用 * 号代表所有字段 select * from vendors; +---------+----------------+--- ...

  3. sql查询语句查询顺序

    一 SELECT语句关键字的定义顺序 SELECT DISTINCT <select_list> FROM <left_table> <join_type> JOI ...

  4. [mysql]当mysql查询语句查询的结果为空时,返回query结果是什么类型的呢?

    php > $con = mysql_connect('localhost' , 'hnb' , 'alyHnb2015'); php > print_r($con);Resource i ...

  5. Mysql IN语句查询

    语法: WHERE column IN (value1,value2,...) WHERE column NOT IN (value1,value2,...) 1.in 后面是记录集,如: selec ...

  6. mysql select语句查询流程是怎么样的

    select查询流程是怎么样的 mysql select查询的数据是查询内存里面,如果没有查询的数据没有在内存,就需要mysql的innodb引擎读取磁盘,将数据加载的内存后在读取.这就体现了,mys ...

  7. mysql查询语句 查询方式

  8. sqlserver 把两个sql查询语句查询出来的两张表合并成一张表

    第一个sql语句 select companyname gsmc,zb zhibiao from t_gsndzb left join t_companycode on t_gsndzb.gsbh=t ...

  9. oracle查询语句查询增加一列内容

    select a,sys_guid() as b from mytable sys_guid() 是生成带分隔符(-)的GUID的自定义函数 查询B表的内容插入A表,MY_ID是A表的主键不可为空,因 ...

随机推荐

  1. Bug报告提交规范

    首先声明,bug的测试规范应该在公司的正式文档建立.本建议非正式文档,有些内容可能不正确,有些内容可能需要继续商榷,甚至有些内容同公司规范有冲突.如果发现问题,直接忽略本文相应内容.本帖本意仅就工作中 ...

  2. csv文件乱码

    问题描述: 生成的csv文件,设置为UTF-8格式,在windows上用EXCEL打开的话会乱码,在linux上用vim或者cat打开查看正常:设置为GBK格式的话,在windows上用EXCEL打开 ...

  3. 重新使用Eclipse建立安卓工程遇到的问题

    很早之前用过Eclipse建立安卓工程,很久没用了,最近打算用Eclipse开发安卓程序,我是用谷歌提供的Eclipse集成环境建立的安卓工程,发现有了一些变化,而且遇到一点问题,这几天不断学习,终于 ...

  4. Codechef:Fibonacci Number/FN(二次剩余+bsgs)

    题面 传送门 前置芝士 \(bsgs\),\(Cipolla\) 题解 因为题目保证\(p\bmod 10\)是完全平方数,也就是说\(p\bmod 5\)等于\(1\)或\(-1\),即\(5\)是 ...

  5. django入门-测试-part5

    尊重作者的劳动,转载请注明作者及原文地址 http://www.cnblogs.com/txwsqk/p/6515996.html 完全翻译自官方文档 https://docs.djangoproje ...

  6. pandas.concat连接dataframe

    https://blog.csdn.net/stevenkwong/article/details/52528616

  7. sql注入实例详解(二)

    前言 这篇文章就是一个最基本的SQl手工注入的过程了.基本上在sqlilabs上面的实验,如果知道了其中的全部知识点,都可以通过以下的步骤进行脱裤.下面的这个步骤也是其他的脱裤手段的基础.如果想要精通 ...

  8. 我永远喜欢我的偶像 KIKU

  9. leetcode-409-Longest Palindrome(统计字母出现次数)

    题目描述: Given a string which consists of lowercase or uppercase letters, find the length of the longes ...

  10. 47.ActiveMQ集群

    (声明:本文非EamonSec原创) 使用ZooKeeper实现的Master-Slave实现方式,是对ActiveMQ进行高可用的一种有效的解决方案,高可用的原理:使用ZooKeeper(集群)注册 ...