看板 Database 關於我們 聯絡資訊
select a,b from ( select table1.id,table2.d as a -- 將 table1.a 替代成 table2.d from table1 inner join table2 on table1.a = table2.c ) as t1 inner join ( select table1.id,table2.d as b -- 將 table1.b 替代成 table2.d from table1 inner join table2 on table1.b = table2.c ) as t2 on t1.id = t2.id where t1.id = 1 ※ 引述《BigLoser (大魯蛇)》之銘言: : 資料庫名稱:mssql : 內容/問題描述: : table1 talbe2 : id a b c d : 1 01 02 01 小明 : 2 02 02 02 小華 : 希望可以一段sql指令可以 : select table1.a, table1.b from table where id=1 : 得到結果 : a b : 小明 小華 : 請問該怎麼下,謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 210.61.233.210 ※ 文章網址: http://www.ptt.cc/bbs/Database/M.1403596354.A.4F3.html
BigLoser:請問一下,一定得用作種作法嗎? 似乎效率不好? 06/24 17:04
cutekid:#1JgI7Tby 中 scpisces 的作法比較好 06/25 08:39