【发布时间】:2012-12-10 14:26:24
【问题描述】:
在我的 sql 脚本中,我有这个:
insert into @res
select
case
when x = 'tblDoll' then (...)
when x = 'tblCar' then (...)
when x = 'tblRocket' then
if rel_table_id = @old_id
(select x.price from tableInDb x where x.id = rel_table.toy_id)
end
from rel_table
where my_toy_id = @toy_id
@old_id 是一个输入参数。
但 if 中的某些内容返回语法错误。 rel_table_id 是 rel_table 的 id。如何在其中放置 if 条件?
【问题讨论】:
标签: sql sql-server tsql syntax