另一个帖问过:http://community.csdn.net/Expert/topic/5750/5750338.xml?temp=.2292597t1(標題表)
idt2(回復表1,會有多條回復,關係:t2.t1id=t1.id)
t1id
============
列出t1的數據,以回復數多少排序,怎麼寫?
=========================================select a.*,b.cnt as 回复数
from t1 as a
left join (select t1id,count(*) as cnt from t2 group by t1id) as b on a.id=b.t1id
order by b.cnt desc================
在我的机上可以,在服务器上就不可以了,可能是mysql版本底,不改变版本情况下怎么实现呢?
出错:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select t1id,count(*)
idt2(回復表1,會有多條回復,關係:t2.t1id=t1.id)
t1id
============
列出t1的數據,以回復數多少排序,怎麼寫?
=========================================select a.*,b.cnt as 回复数
from t1 as a
left join (select t1id,count(*) as cnt from t2 group by t1id) as b on a.id=b.t1id
order by b.cnt desc================
在我的机上可以,在服务器上就不可以了,可能是mysql版本底,不改变版本情况下怎么实现呢?
出错:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select t1id,count(*)
你的服务器上的MYSQL版本是多少?
服務器的版本改不了的,怎麼解決這條sql?
from t1 as a ,(select t1id,count(*) as cnt from t2 group by t1id) as b where a.id=b.t1id order by b.cnt desc
from t1 as a ,(select t1id,count(*) as cnt from t2 group by t1id) as b where a.id=b.t1id order by b.cnt desc