作者fumizuki (蒙面加菲狮)
看板Database
标题Re: [SQL ] 判别栏位值的问题
时间Fri Sep 29 07:11:32 2006
※ 引述《smileworm (酷玩)》之铭言:
: 遇到一个问题:
: 先slect 出一个table 然後依照table里一个栏位叫ex 判断
: 如果ex值为 'A' 就join table A
: 反之值为 'B' 就去join table B
: 我想来想去 都想不出来 语法该怎麽下呢?
: 麻烦指教一下
SQL Server?
select case ex when 'A' then A.xx when 'B' then B.xx end as ex
from table t
join A on A.ex=t.ex
join B on B.ex=t.ex
以上...是乱写的...不知道行不行的通....囧
select * from table t join A on A.ex=t.ex where t.ex='A'
union
select * from table t join B on B.ex=t.ex where t.ex='B'
--
▃▅▇▆▄ ▆▂▃ `
逝去感情如何能留住,半点痴情遗留殊不易,██▅▇▄▃ ▇▃▂" .
█████████▃i ▁▄▇
更多凄凄惨惨的遭遇…………██▆▃ █▅▆▃ˍ▄*
◢ ▂█▄▇▅▂▌.
我不知道,王~八~蛋~~! ▂▆███ █▄▃ 。fumizuki。Check。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.184.116.37