先输出产品ID为20的产品 然后在输出其他产品 显示方式产品ID为20的在前面显示其他产品按照排序显示  例如:点击类别电脑 先输出所有电脑产品然后输出电脑周边的一些产品如鼠标键盘等。。按照ID大小排序出来
 
 但是电脑显示在最前面
 

解决方案 »

  1.   

    order by case when id=20 then 0 else 1 end,id
      

  2.   

    "select * from product where classid="&classid&"  order by case when classid="&classid&" then 0 else 1 end,classid"我这样写的对吗 输出没结果
      

  3.   


    我这样写的对吗? 输出没结果"select * from product where classid="&classid&"  order by case when classid="&classid&" then 0 else 1 end,classid"
      

  4.   

    declare @参数 nvarchar(20)
    exec ('select * from product where classid='+@参数+'  order by case when classid='+@参数+' then 0 else 1 end,classid')
      

  5.   

    order by case when id=20 then 1 else 2 end,id
      

  6.   


    ASP开发 我按照你写的也是没有输出。可能是我太笨了 
    <%
     classid = request("classid")
    set rsx=server.createobject("adodb.recordset")
    sqlx="select * from product where classid='&classid&'  order by case when classid='&classid&' then 0 else 1 end,classid"
    rsx.open sqlx,conn,1,1
    if not rsx.eof then
      %>
      

  7.   


    我是ASP语言 我写的对吗,没有输出 <%
     classid = request("classid")
    set rsx=server.createobject("adodb.recordset")
    sqlx="select * from product where classid="&classid&"  order by case when classid="&classid&" then 1 else 2 end,classid"
    rsx.open sqlx,conn,1,1
    if not rsx.eof then
      %>
      

  8.   


    如果是这样怎么写 输出产品Id=20的在前面显示 其他则按照ID大小在后面显示 但是后面显示不要包括ID=20的产品了
      

  9.   


    如果是这样怎么写 输出产品Id=20的在前面显示 其他则按照ID大小在后面显示 但是后面显示不要包括ID=20的产品了
      

  10.   


    不是显示一次 是显示在前 然后在显示出其他的ID的产品 按照ID排序
      

  11.   

    如果你指定是20在第一行,那就:
    select * from xxx where id=20
    union all 
    select * 
    from xxx