select * from product where pro_name="pro1" order by id desc 不是我要的效果   我想实现:
       
       比如表里的id 一次为 1,2,3,5,7,9  我想查出  结果按 5,2,9,7,3,1  就是把 其中的2个特殊的放在前面  其他的  降序排列  请教大家如何写sql呢  我用的是access表   

解决方案 »

  1.   

    比如表里的id字段里的值 顺序是 id=1,id=2,id=3,id=5,id=7,id=9 
                我想查出 结果按 id=5,id=2,id=9,id=7,id=3,id=1 排序  就是 把id为5,id为2的放在查询结果的最前面,其他的数据按降序排列   求教了
      

  2.   

    特殊就加标识吧,比如加排序列,特殊的都是0,其它的都是1这样就好查询了,先order by 特殊列,再其它列
      

  3.   

    select * from product where pro_name="pro1" and id = 5 
    select * from product where pro_name="pro1" and id = 2
    select * from product where pro_name="pro1" and id not in(5,2) order by id desc多查几次。或者是改下表结构,加多个标记字段,例如增加type字段,特殊的置为1,其他置为0.
    select * from product where pro_name="pro1" and id not in(5,2) order by type desc,id desc
      

  4.   

    select * from product where pro_name="pro1" and id in(特殊) order by id desc
    union
    select * from product where pro_name="pro1" and id not in (特殊) order by id desc