我试了一下,这样就能得到你想要的结果,不过好像通用性不强。 select name from A where id>=(select content from B where cid=1) 因为select content from B where cid=1得到的结果为"2,3",后面的id好像只能看得见 "2",为什么会看不见3我就不知道了。 要是content的内容为"2,3,1,4,5"的话,你可以再加个函数就是 id>=min(select content from B where cid=1) and id<=max(select content from B where cid=1) 后面这一句我没有测试过,前面的就有,有什么错漏的话请包涵就是了。
但按照这种写法select name from A where id>=(select content from B where cid=1) 的话,即使不在content中的id也会查出来了,比如content为2,4,7的话,那么2,3,4,5,6,7都会查出来,但我只要2,4,7的记录
1 2
1 3
1 4
1 5
保存为4条记录
这应该怎么解决啊.
select name from A where id>=(select content from B where cid=1)
因为select content from B where cid=1得到的结果为"2,3",后面的id好像只能看得见
"2",为什么会看不见3我就不知道了。
要是content的内容为"2,3,1,4,5"的话,你可以再加个函数就是
id>=min(select content from B where cid=1) and id<=max(select content from B where cid=1)
后面这一句我没有测试过,前面的就有,有什么错漏的话请包涵就是了。
的话,即使不在content中的id也会查出来了,比如content为2,4,7的话,那么2,3,4,5,6,7都会查出来,但我只要2,4,7的记录
1.如果第一位是数字的字符串被用于一个算术运算中,那么它被转为这个数字的值。
例如:上面结果集:'2,3'被转为数字2,后面的都丢了。
2.如果一个包含字符和数字混合的字符串不能被正确地转换为数字,那么它被转换成0.
这个好像已回答过了吧http://community.csdn.net/Expert/topic/4350/4350282.xml?temp=.7628748