Re: [SQL ] [請益]兩個無關table join的語法
※ 引述《sanisan (sanisan)》之銘言:
: 請教大家一個table join的問題。
: 資料庫是 mysql 5.0 on Linux
: 我有兩個table: tA & tB,scheme如下
: ------------------------------------------
: tA:
: tA_id as int
: tA_date as datetime
: tA_data1 as vchar
: tB:
: tB_id as int
: tB_date as datetime
: tB_data2 as vchar
: ------------------------------------------
: tA 與 tB之間沒有關係(所以無法用 JOIN ...on ...串接 )。
: 有辦法 join 兩個 table 並按照 時間排序嗎?
: 即類似下方的輸出
SELECT tA_id as t_id, tA_date as t_date FROM tA
UNION
SELECT tB_id as t_id , tB_date as t_date FROM tB
ORDER BY 2
LIMIT 0,5
最關鍵的是 ORDER BY 2 <-- 用第二個欄位排序
用眼睛餘光對了一下資料,似乎沒有破綻。
謝謝R大的提點,感恩 (  ̄□ ̄)/ <( ̄ㄧ ̄ )<( ̄ㄧ ̄ )<( ̄ㄧ ̄
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 212.42.236.140
推
02/05 16:45, , 1F
02/05 16:45, 1F
討論串 (同標題文章)