问题描述
我在用access的时候,出现了一个问题,不知道为什么ORDER BY 不起作用,谁能帮我解答一下。SELECT announce_master.counter ,(SELECT TOP 1 m_group.gname FROM m_user,m_group,group_info WHERE announce_master.uid = m_user.uid AND m_user.uid = group_info.uid AND m_group.gid = group_info.gid AND group_info.uid = m_user.uid AND m_group.gid <> '00000000000000000000000000000000' AND m_group.gid <> '11111111111111111111111111111111' ORDER BY m_group.viewid) as gname FROM ((announce_master LEFT OUTER JOIN m_user ON announce_master.uid = m_user.uid) LEFT OUTER JOIN announce_category ON announce_master.category_id = announce_category.category_id) WHERE announce_master.counter IN (28,9,10,11,12,29,30)ORDER BY 2 ASC 问题补充:SQL和·Oracle的时候用列名gname 可以,可ACCESS的时候就不可以。wangqj 写道
解决方案
1、刚才没看见,你用了两个Order by ,Order by和top一起用的时候可能查出来多于你要的结果2、order by 不支持表达式
解决方案二:
Order by后面跟的是列名