select a.*,b.recommend from table1 a,table2 b
where a.uid=b.uid and
a.cate=3 and b.recommend<>0
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语句大全
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)