單獨測試這個函數返回結果是正常,但用在where 後作為條件時,好像沒有起作用?
select * from orgstruct where class in (select zhou.dbo.test())
or
select * from orgstruct where class in (zhou.dbo.test())
...全文
943打赏收藏
自定義函數作為條件的問題
自定義函數 zhou.dbo.test() 返回結果是一個字符串: 'p','u' 單獨測試這個函數返回結果是正常,但用在where 後作為條件時,好像沒有起作用? select * from orgstruct where class in (select zhou.dbo.test()) or select * from orgstruct where class in (zhou.dbo.test())
所以select * from orgstruct where class in (zhou.dbo.test())
等同于
select * from orgstruct where class in ("'p','u'")
而不是
select * from orgstruct where class in ('p','u')