Exists in the use of 003 mysql

You can use the mysql exists in two places, one at the library or create a time table, with the use if one is in a subqueries.

# 和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');

Guess you like

Origin www.cnblogs.com/chenych/p/11223751.html
Recommended