你的<>和=号是不是反了?select * from table1 where dateDiff(day,idate,getdate())=0 order by vip
union all
select * from table2 where dateDiff(day,idate,getdate())<>0 order by idate

解决方案 »

  1.   

    select * from table1 where dateDiff(day,idate,getdate())<>0 order by idate
    union all
    select * from table2 where dateDiff(day,idate,getdate())=0 order by vip
      

  2.   

    关键是这个结果,即不是按VIP按序也不是按时间。
    我预想的应是前面排的是今天发布的信息,并按VIP等级
    然后显示完今天的再显示其它天的,并只按时间。如:
    +------------------------------------+
    | ID   |    VIP   |     IDate        |
    +------+----------+------------------+
    | 01   |    2     | 2005-05-28 12:05 |
    +------+----------+------------------+
    | 02   |    1     | 2005-05-28 15:05 |
    +------+----------+------------------+
    | 03   |    0     | 2005-05-28 17:05 |
    +------+----------+------------------+
    | 04   |    0     | 2005-05-27 17:05 |
    +------+----------+------------------+
    | 05   |    2     | 2005-05-26 10:05 |
    +------+----------+------------------+
    | 06   |    1     | 2005-05-25 17:05 |
    +------+----------+------------------+
      

  3.   

    我源程序中=与<>符号没错。在这里我大意写错了!
      

  4.   

    select * 
    from table1
    order by case when dateDiff(day,idate,getdate())=0 then 0 
                  else 1 
             end,
             case when dateDiff(day,idate,getdate())=0 then vip 
                  else idate 
             end desc