早教吧 育儿知识 作业答案 考试题库 百科 知识分享

我加入where子句后不能运行这段语句没问题SELECTDISTINCTs.usernameasusername,s.uidasuserid,s.creditasplnum,s.viewnumasonclick,b.blogidasid,b.subjectastitle,FROMUNIXTIME(b.dateline)asnewstime,s.usertypeasbefromFROMu

题目详情
我加入where子句后不能运行这段语句没问题 SELECT DISTINCT s.username as username,s.uid as userid,s.credit as plnum,s.viewnum as onclick,b.blogid as id,b.subject as title,FROM_UNIXTIME(b.dateline) as newstime,s.usertype as befrom FROM uchome_space s INNER JOIN uchome_blog b ON s.uid=b.uid GROUP BY s.uid ORDER BY s.viewnum DESC LIMIT 3 而加入了where子句之后WHERE s.username='aessjz' 。aessjz是个用户名 SELECT DISTINCT s.username as username,s.uid as userid,s.credit as plnum,s.viewnum as onclick,b.blogid as id,b.subject as title,FROM_UNIXTIME(b.dateline) as newstime,s.usertype as befrom FROM uchome_space s INNER JOIN uchome_blog b ON s.uid=b.uid WHERE s.username='aessjz' GROUP BY s.uid ORDER BY s.viewnum DESC LIMIT 3 就无法运行了 是where的位置问题吗
▼优质解答
答案和解析
出什么错误提示么或者是innerjoin了以后该字段没有这个用户名 SELECT DISTINCT s.username as username,s.uid as userid,s.credit as plnum,s.viewnum as onclick,b.blogid as id,b.subject as title,FROM_UNIXTIME(b.dateline) as newstime,s.usertype as befrom FROM uchome_space s INNER JOIN uchome_blog b ON s.uid=b.uid GROUP BY s.uid having s.username='aessjz' ORDER BY s.viewnum DESC LIMIT 3 这样试试 另外总觉得你前边那句话也有问题,好多字段没在group by里也没在聚合函数里