UNION   排除重复行
union all 不排除
select bl_student_id from books_loaned
union
select reserved_student_id from books_reserved;

解决方案 »

  1.   

    呵呵,最好对字段用一样的别名。如
    select field1 a,field2 b from tablea 
    union 
    select field2 a,field2 b from tableb
      

  2.   

    对楼上几位做个补充:
    union 起来的多个select 语句中不能含有order by 
      

  3.   


    union all!楼上的大虾又犯错了:union可以使用order by 
      

  4.   

    to gxdq(石老人) :
    在union连接的select 语句中,只能是最后一个可以用order by
    不是union all吧.