sql 备忘
select * from (select nick, (shopid * id) as a from shopkeeper order by a(计算列排序) desc) as T2(mysql的怪癖吗,sqlserver 貌似没有后面的as 。。也可以) limit 0,5
wrong:
SELECT num, nome FROM (SELECT 0 as num, tema as nome FROM pesquisa AS t1) LEFT JOIN (SELECT COUNT(id) as num, tema as nome FROM pesquisa WHERE (YEAR(ano_defesa) = 0 OR 1=1) GROUP BY tema AS t2))
right:
try to change the query to:
Code:
SELECT num, nome FROM (SELECT 0 as num, tema as nome FROM pesquisa) AS t1 LEFT JOIN (SELECT COUNT(id) as num, tema as nome FROM pesquisa WHERE (YEAR(ano_defesa) = 0 OR 1=1) GROUP BY tema) As t2 On t1.num=t2.num
Note that the alias is outside the () and you must add a join condition.

浙公网安备 33010602011771号