mysql中一个字段同时满足多个条件,(3个以上)
不是同时,额,是满足就行, 我用or的时候只能放三个条件,然后 跟上order by
id desc
select * from message where (typeid=31) or (typeid=30) or (typeid=32) or <typeid=33) order by id desc;
次偶 typeid前面变成<,所以才出错= = 展开
SELECT
t.file_id
FROM
app_polly_file_labels t
WHERE
t.style = '清新'
or t.style = '甜美'
or t.style = '韩潮来袭'
GROUP BY t.file_id
HAVING count(t.file_id)=3
或者
SELECT
a.file_id
FROM
app_polly_file_labels a
INNER JOIN app_polly_file_labels b ON a.file_id = b.file_id
INNER JOIN app_polly_file_labels c ON a.file_id = c.file_id
WHERE
a.style ='清新'
AND b.style ='甜美'
AND c.style ='韩潮来袭'
扩展资料:
sql常用的复杂查询语句
一、选择指定的列
select Sno as 学号,Sname as 姓名 from student
select Sno,Sname from student
二、查询全部列
select * from student
三、对查询后的指定列进行命名
select Sname as 姓名,(2014-Sage) as 出生年 from student
select Sname ,(2014-Sage) from student
四、消除取值重复的行
select distinct Sno as 选修了课程的学生学号 from SC
select distinct Sno from SC
五、选择表中若干元组,满足条件的
select Sname as 学生姓名 from student where Sdept='IS'
参考链接:SQL语句大全
推荐于2017-04-22
或者
select * from message where typeid IN ( 31, 30, 32, 33) order by id desc;
select * from message where (typeid=31) and (typeid=30) and (typeid=32) and <typeid=33) order by id desc;