#比较

等于
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. C# 连接sqlite数据库

    web.config <connectionStrings> <add name="SQLiteDB" connectionString="Data S ...

  2. Could not find any resources for the specified culture or the neutral culture

    问题解决办法是: 打开资源文件,将access modifier:下拉项设置为“internal”即可

  3. 注册IIS的批处理

    新建记事本 输入以下内容 @echo 开始注册Asp.net!%SystemDrive%\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_reg ...

  4. python网络编程--协程

      1.协程 协程:是单线程下的并发,又称微线程,纤程.英文名Coroutine.一句话说明什么是线程:协程是一种用户态的轻量级线程,即协程是由用户程序自己控制调度的.. 需要强调的是: 1. pyt ...

  5. css3 animation动画使用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. java—ThreadLocal模式与OSIV模式(53)

    ThreadLocal: 维护线程局部的变量. ThreadLocal 不是线程.它就是一个Map.可以保存对象. 它保存的对象,只与当前线程相关. 当一个线程还没有运行完成时,如果不想传递数据,可以 ...

  7. BZOJ4012 [HNOI2015]开店 (动态点分治)

    Description 风见幽香有一个好朋友叫八云紫,她们经常一起看星星看月亮从诗词歌赋谈到 人生哲学.最近她们灵机一动,打算在幻想乡开一家小店来做生意赚点钱.这样的 想法当然非常好啦,但是她们也发现 ...

  8. robot framework接口测试之一-完整的测试用例

    *** Settings *** Library Collections Library json Library requests Library RequestsLibrary Library H ...

  9. HTML Strip Char Filter

    The html_strip character filter strips HTML elements from the text and replaces HTML entities with t ...

  10. jdk命令行工具(一)

    1.概述 熟悉java开发的人应该都知道在jdk的bin目录下有许多的工具,这些工具主要用于监视虚拟机和故障处理.这些故障处理工具被Sun公司称作为“礼物”附赠给JDK的使用者,并在软件的使用说明中把 ...