带EXISTS关键字的子查询

EXISTS关字键字表示存在。

EXISTS 判断某个sql语句的有没有查到结果 有就返回真  true 否则返回假 False

如果条件成立 返回另外一条sql语句的返回结果

返回结果了

  1. mysql> select * from employee where EXISTS(select id from department where name='技术');
  2. +----+------------+--------+------+--------+
  3. | id | name | sex | age | dep_id |
  4. +----+------------+--------+------+--------+
  5. | 1 | mike | male | 18 | 200 |
  6. | 2 | alex | female | 48 | 201 |
  7. | 3 | jack | male | 38 | 201 |
  8. | 4 | yuanhao | female | 28 | 202 |
  9. | 5 | liwenzhou | male | 18 | 200 |
  10. | 6 | jingliyang | female | 18 | 204 |
  11. +----+------------+--------+------+--------+
  12. 6 rows in set (0.00 sec)

子查询也查不出结果 exists 返回是false

  1. mysql> select * from employee where EXISTS(select id from department where name='it');
  2. Empty set (0.00 sec)

mysql 数据操作 多表查询 子查询 带EXISTS关键字的子查询的更多相关文章

  1. mysql 数据操作 多表查询 目录

    mysql 数据操作 多表查询 准备 多表连接查询介绍 mysql 数据操作 多表查询 多表连接查询 笛卡尔积 mysql 数据操作 多表查询 多表连接查询 内连接 mysql 数据操作 多表查询 多 ...

  2. mysql 数据操作 单表查询 目录

    mysql 数据操作 单表查询 mysql 数据操作 单表查询 简单查询 避免重复DISTINCT mysql 数据操作 单表查询 通过四则运算查询 mysql 数据操作 单表查询 concat()函 ...

  3. mysql 数据操作 单表查询 where 约束 目录

    mysql 数据操作 单表查询 where约束 between and or mysql 数据操作 单表查询 where约束 is null in mysql 数据操作 单表查询 where约束 li ...

  4. mysql 数据操作 单表查询 group by 分组 目录

    mysql 数据操作 单表查询 group by 介绍 mysql 数据操作 单表查询 group by 聚合函数 mysql 数据操作 单表查询 group by 聚合函数 没有group by情况 ...

  5. mysql 数据操作 多表查询 子查询 介绍

    子查询就是: 把一条sql语句放在一个括号里,当做另外一条sql语句查询条件使用 拿到这个结果以后 当做下一个sql语句查询条件mysql 数据操作  子查询 #1:子查询是将一个查询语句嵌套在另一个 ...

  6. mysql 数据操作 多表查询 子查询 带IN关键字的子查询

    1 带IN关键字的子查询 #查询平均年龄在25岁以上的部门名关键点部门名 以查询员工表的dep_id的结果 当作另外一条sql语句查询条件使用 in (sql语句) mysql ; +-------- ...

  7. mysql 数据操作 多表查询 子查询 带比较运算符的子查询

    带比较运算符的子查询 #比较运算符:=.!=.>.>=.<.<=.<> #查询大于所有人平均年龄的员工名与年龄 思路 先拿到所有人的平均年龄然后 再用另外一条sql ...

  8. mysql 数据操作 单表查询 where约束 like 模糊匹配

    mysql> select * from employee; +----+------------+--------+-----+------------+-----------+------- ...

  9. mysql 数据操作 单表查询 where约束 is null in

    需求找出年龄是 81 或者 73 或者 28 mysql ; +----+-----------+--------+-----+------------+-----------+----------- ...

随机推荐

  1. javaEE mvc样例具体解释

    一个不错的样例值得细细品味: 以下依照包顺序将代码贴出来供大家參考: IEmpDAO package org.lzch.dao; import java.util.List; import org.l ...

  2. hbase集群部分节点HRegionServer启动后自动关闭的问题

    参考链接 http://f.dataguru.cn/thread-209058-1-1.html 我有4HRegionServer节点,1个master,其中3个是unbuntu 系统,2个节点是ce ...

  3. LR中点鼠标做关联(winsock协议)

    转自:http://blog.csdn.net/zeeslo/article/details/1661791 今天写一下winsock的关联操作. 以前看过一个文档.在英文版的讲winsock的,其中 ...

  4. Matlab中imread函数使用报错“不应为MATLAB 表达式”分析

    问题描述: 使用imread读取特定路径下的文件时,会提示出错! >> mytest错误: 文件:mytest.m 行:10 列:87不应为 MATLAB 表达式. 出错行: Images ...

  5. 第四章 Spring.Net 如何管理您的类___对象的自动装配

    由于这几天都比较忙,所以对笔记暂时没有更新. Spring.NET具有自动装配的能力,也就是说,Spring.NET可以通过对象的定义自动分辨某个对象的协作对象.自动装配是针对单个对象(按:针对每个协 ...

  6. Ini操作类

    using System; using System.Collections; using System.Collections.Generic; using System.Linq; using S ...

  7. 【RF库Collections测试】Get Dictionary Values

    Name:Get Dictionary ValuesSource:Collections <test library>Arguments:[ dictionary ]Returns val ...

  8. JS时间格式化函数

    Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month & ...

  9. 【Java nio】 NonBlocking NIO

    package com.slp.nio; import org.junit.Test; import java.io.IOException; import java.net.InetSocketAd ...

  10. LeetCode——Valid Anagram

    Description: Given two strings s and t, write a function to determine if t is an anagram of s. For e ...