五月天乡水百度云:sql编程哪里错了?

来源:百度文库 编辑:高校问答 时间:2024/04/30 00:15:20
sql编程哪里错了?
悬赏分:0 - 提问时间2006-8-21 21:56 问题为何被关闭
if @case='1'
@sql='update [plus_down_download] set dayhits=dayhits+1 where id='+@plus_down_download_id
if @case='2'
@sql='update [plus_down_download] set dayhits=1 where id='+@plus_down_download_id
if @case='3'
@sql='update [plus_down_download] set dayhits=dayhits+1 where id='+@plus_down_download_id
if @case='4'
@sql='update [plus_down_download] set weekhits=weekhits+1 where id='+@plus_down_download_id
if @case='5'
@sql='update [plus_down_download] set weekhits=1 where id='+@plus_down_download_id

SQL里变量赋值要使用SET关键字,如:

@sql='update [plus_down_download] set dayhits=dayhits+1 where id='+@plus_down_download_id
改为
SET @sql='update [plus_down_download] set dayhits=dayhits+1 where id='+@plus_down_download_id

怎么不使用 case when ?