作者sanisan (sanisan)
看板Database
标题Re: [SQL ] [请益]两个无关table join的语法
时间Wed Dec 16 21:00:21 2009
※ 引述《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
1F:推 QQFOX:(  ̄□ ̄)/ <( ̄ㄧ ̄ )<( ̄ㄧ ̄ )<( ̄ㄧ ̄ 02/05 16:45