Home > Database > Mysql Tutorial > mysqlin的两种用法_MySQL

mysqlin的两种用法_MySQL

WBOY
Release: 2016-06-01 13:01:38
Original
1990 people have browsed it

简述MySQL 的in 的两种用法:

他们分别是在 in 关键字后跟一张表(记录集),以及在in后面加上字符串集。

先讲后面跟着一张表的。

首先阐述三张表的结构:

s(sno,sname.sex,age,dept) //学生信息表

c(cno,cname,tname) //课程信息表

sc(sno,cno,grade) //课程选修信息表

update sc set grade = 0 where sc.cno in (select cno from c where c.cname = '物理') and sc.grade

这个例子里的in后面就跟着一张由select语句 产生的一张临时表。

好,那么现在再来看下面的in后面跟着一个字符串集,其实也不见得非得是字符串集。

select * from s where sname in ('aaa','bbb','ccc');

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template