Re: [問題] 請問一個SQL

看板Web_Design作者 (小歐)時間19年前 (2005/12/12 18:52), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
※ 引述《PsMonkey (痞子軍團團長)》之銘言: : 硬幹法 : select s.*, m.grade as Math, a.grade as Art, e.grade as English : from student as s, : (select * from class where course='math') as m, : (select * from class where course='art') as a, : (select * from class where course='english') as e : where s.name *= m.name and s.name *= a.name and s.name *= e.name : 這個語法應該是 OK 的,不過,看個概念就好... XD : *= 應該是 left outter join,我忘記標準的 SQL 要怎麼寫了... : 不過,說真的為什麼只能用 SQL 呢? ==.==? : 有時候把事情都丟給 SQL,未必是好事情 How about this? select student.*, (select grade from class where course = 'Math' and student.name=class.name) as Math, (select grade from class where course = 'Art' and student.name=class.name) as Art, (select grade from class where course = 'English' and student.name=class.name) as English from student; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.121.188.247 ※ 編輯: ojinjin 來自: 59.121.188.247 (12/12 22:32)
文章代碼(AID): #13dLP_Zx (Web_Design)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 4 篇):
文章代碼(AID): #13dLP_Zx (Web_Design)