看板 Database 關於我們 聯絡資訊
※ 引述《fishfish0000 (小魚仔~)》之銘言: declare @t1 table(name int, place int, speed float,[time] float) insert @t1 values (1,1,31,11) insert @t1 values (2,2,32,12) declare @t2 table(name int, place int, speed float,[time] float) insert @t2 values (2,2,32,12) declare @t3 table(name int, place int, speed float,[time] float) insert @t3 values (3,1,33,13) --偷用樓上大大的範例 XD select * from @t1 UNION select * from @t2 UNION select * from @t3 -- result [name] [place] [speed] [time] 1 1 31 11 2 2 32 12 3 1 33 13J -- result 我試過這樣的寫法 , 得到的結果如上 union的寫法就是你的直式寫法 只是union會自動幫你做distinct 環境是 MSSQL 2005 : 是ms-sql... : 想請教大大們… : 查到的資料都是橫的合併(ex:join) : 要合併的資料表,每個欄位的都是一樣的。只是要把全部合併成一張 : ex: : table a : date num name : 1001 5 Tom : table b : date num name : 0205 1 Linda : table c : date num name : 0310 3 Sherry : 0607 4 Ben : ======================== : 想要的結果是這樣: : table abc : date num name : 0205 1 Linda : 0310 3 Sherry : 0607 4 Ben : 1001 5 Tom : 感謝解答的大大… : 試過union也還是橫的合併!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.128.252.130