select id,1price price,'1price' price_day from paper_price where 1price>400000
union all
select id,2price price,'2price' price_day from paper_price where 2price>400000
union all
select id,3price price,'3price' price_day from paper_price where 3price>400000
union all
select id,4price price,'4price' price_day from paper_price where 4price>400000
union all
select id,5price price,'5price' price_day from paper_price where 5price>400000
union all
select id,6price price,'6price' price_day from paper_price where 6price>400000
union all
select id,7price price,'7price' price_day from paper_price where 7price>400000
union all

解决方案 »

  1.   

    union all直接返回所有记录union先连接结果集再删除重复的记录然后进行排序返回结果集
      

  2.   

    select id , [1price] price , price_day = '1price' from paper_price where [1price] > 400000
    union all
    select id , [2price] price , price_day = '2price' from paper_price where [2price] > 400000
    ...
    select id , [7price] price , price_day = '7price' from paper_price where [7price] > 400000
      

  3.   

    select   id,1price   price, '1price '   price_day   from   paper_price   where   1price> 400000 
    union   all 
    select   id,2price   price, '2price '   price_day   from   paper_price   where   2price> 400000 
    union   all 
    select   id,3price   price, '3price '   price_day   from   paper_price   where   3price> 400000 
    union   all 
    .............................................
      

  4.   

    多少个字段就用多少个union all
    1,4,6楼的都可.
      

  5.   


    select   id,1price   price, '1price '   price_day   from   paper_price   where   1price> 400000 
    union   all 
    select   id,2price   price, '2price '   price_day   from   paper_price   where   2price> 400000 
    union   all 
    select   id,3price   price, '3price '   price_day   from   paper_price   where   3price> 400000 
    union   all 
    select   id,4price   price, '4price '   price_day   from   paper_price   where   4price> 400000 
    union   all 
    select   id,5price   price, '5price '   price_day   from   paper_price   where   5price> 400000 
    union   all 
    select   id,6price   price, '6price '   price_day   from   paper_price   where   6price> 400000 
    union   all 
    select   id,7price   price, '7price '   price_day   from   paper_price   where   7price> 400000