作者ojinjin (小欧)
看板Web_Design
标题Re: [问题] 请问一个SQL
时间Mon Dec 12 18:55:28 2005
※ 引述《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)