+ -
当前位置:首页 → 问答吧 → in的问题

in的问题

时间:2011-12-02

来源:互联网


select * from A where cid in (
select ''''+replace(cinstrumentid,',',''',''')+'''' as dd from B 
where iautoid='7873'
)



如果用下面的语就能结果,
直接走select ''''+replace(cinstrumentid,',',''',''')+'''' as dd from B where iautoid='7873'的结果也是 'AA1','BB','CC',为什么上面的就没结果了????


select * from A where cid in(
'AA1','BB','CC'
)

作者: dengkz1   发布时间: 2011-12-02

select 出来本身就是字符串,你没必要加引号,括号里的加引号是因为加了引号才是字符串

作者: ssp2009   发布时间: 2011-12-02

select cinstrumentid from B where iautoid='7873'

出来的结果是:AA1,BB,CC

不replace,可以吗?

作者: dengkz1   发布时间: 2011-12-02

引用 2 楼 dengkz1 的回复:

select cinstrumentid from B where iautoid='7873'

出来的结果是:AA1,BB,CC

不replace,可以吗?

e 你大可以试试。实践出真理

作者: Beirut   发布时间: 2011-12-02

select * from A where cid in (
  select cinstrumentid from B where iautoid='7873'
)

实践出不行.


select cinstrumentid from B where iautoid='7873'
上面这句结果是AA1,BB,CC

作者: dengkz1   发布时间: 2011-12-02

select * from A where cid in (
  select ltrim(rtrim(cinstrumentid)) from B where iautoid='7873'
)

作者: AcHerat   发布时间: 2011-12-02

引用 5 楼 acherat 的回复:
select * from A where cid in (
select ltrim(rtrim(cinstrumentid)) from B where iautoid='7873'
)


还是不行
cid 和cinstrumentid 都是varchar

作者: dengkz1   发布时间: 2011-12-02