MySql 杂记 之一

一、 查询时排除重复 : distinct

想用查询语句查询某字段的不重复的值,需要使用 distinct 关键字

select distinct type from user;

二、 WHERE ... IN 和 子查询结合

把子查询某字段的结果作为组合在 WHERE ... IN 中做条件使用:

update  user_profile set type = 2 WHERE uid  IN ( select uid from user where status = 1 );
原文地址:https://www.cnblogs.com/zjfazc/p/2859793.html