码迷,mamicode.com
首页 > 数据库 > 详细

003 mysql中exists的使用

时间:2019-07-22 10:21:55      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:base   creat   from   sele   create   tab   exist   条件   set   

mysql中exists可以使用在两个地方,一个是在创建库或者表的时候,配合if 使用,一个是在子查询中。

# 和if一起使用,对库或表都可以使用
create database if not exists yaco charset utf8;
drop database if exists yaco;


# 在子查询中使用,返回True或者False,条件满足时执行前面的代码
select * from tb1 where exists(select id from tb2 where name = 'yaco');

003 mysql中exists的使用

标签:base   creat   from   sele   create   tab   exist   条件   set   

原文地址:https://www.cnblogs.com/chenych/p/11223751.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!