用union 可以解决,但、mysql不支持union.
可以这样解决:
create temporary table tem_table type=heap select ... from table1 where...
insert into tem_table select ... from table2 where ...
select * from tem_table order by ....
drop table tem_table
可以这样解决:
create temporary table tem_table type=heap select ... from table1 where...
insert into tem_table select ... from table2 where ...
select * from tem_table order by ....
drop table tem_table
比如第一個表有5條記錄,第二個表有6記錄
這樣第一條語句就會返回30條記錄
要返回沒有重復的記錄:有三種情況
select 表1.字段1,表2.字段2 from 表1,表2 where 表1.字段=表2.字段
(其中表1.字段,表2.字段是這兩個表的連接字段,或是主外鍵關系)
上面的語句也可以用
select 表1.字段1,表2.字段2 from 表1 join 表2 on 表1.字段=表2.字段