asp的sql查询语句:怎样把字段作为自定义函数的变量?

来源:百度知道 编辑:UC知道 时间:2024/05/17 07:16:39
'这是一个函数
Function hanshu(mm)
if mm="yes" then
hanshu=1
else
hanshu=2
end if
end Function

sql="select nn form dd where "&hanshu(nn)
我的这个sql要求:调用hanshu这个函数,函数的变量要求使用这个sql的nn这个字段。如何写呢?

调用函数我做到的了。但是把这个表格的一个字段(nn)作为hanshu的传递变量mm,该如何写呢?

希望高手明示。给出具体步骤。多谢。
kxl361的方法我知道的。但关键是我的这个函数是个非常复杂的函数,不是我这样列举的这样简单的。我只希望知道如何才能把这个字段的值传递到函数中,并且用sql语句表达出来。当然也许本身没有这种方法。如果有更好的解决方案还望不吝赐教。

楼主这样写实不可能实现的,建议楼主在sql里面用case 语句来做

case 列名 when 值1 then 返回值1
when 值2 then 返回值2
when 值3 then 返回值3
else 返回值4
end
===========================================
select nn
from dd
where (case nn when 'yes' then 1
else 2
end)

我理解错了,
期待答案