sql查询。查询表A的a列值中具有和表B中b列(用字符串存储的字段,字符串用逗号隔开)值的记录。

如题所述

建议使用replace函数。
具体方法为:将B表备份,暂记为BB表吧,然后对B表的b列进行逗号字符替换处理,继而再对A表和BB表关联查询。所用到的语句及步骤为:
1.create table BB as select b from B ;
2.update BB set b=replace(b,',','');
3.select A.* from A,BB where A.a=BB.b
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-11-23
SELECT * FROM A WHERE A.a in (select b from B);