我的这段SQL为何输出不对

来源:百度知道 编辑:UC知道 时间:2024/05/06 13:37:30
select top 2 * from photo where ClassID in (select ClassID from photo where PhotoID >= "&request("PhotoID")&") order by ClassID desc
我的表的构造如下photo表中
Photoid Photoname ClassID
5 张 2
4 李 3
3 王 2
2 中 2
1 山 2
假设当 PhotoID=1时 2 3 4 5中 classid=2的前2个
输出就是


请问高手我这段代码对吗?

SELECT TOP 2 Photoname
FROM photo
WHERE (ClassID =
(SELECT classid
FROM photo
WHERE PhotoID ="&request("PhotoID")&")) AND (Photoid <> " & request("PhotoID") & ")
ORDER BY Photoid

代码错误select top 2 * from photo where ClassID in (select ClassID from photo where PhotoID >= "&request("PhotoID")&") order by ClassID desc 中间有个*号,这个不要