我有一个表table_a 里面有一个字段field中保存了用户的编号,编号使用逗号隔开,例如:379,380,386,390,503我做查询select * from user where user_id in (379,380,386,390,503); 是正确的。 但是当我查询 select * from user where user_id in (select field from table_a where id = 1);时却报oracle ORA-01722无效数字
答:select * from user where INSTR( (select ',' || field || ',' from table_a where id = 1), ',' || TRIM(TO_CHAR(user_id )) || ',' ) > 0
答:select * from user where INSTR( (select ',' || field || ',' from table_a where id = 1), ',' || TRIM(TO_CHAR(user_id )) || ',' ) > 0
本文探讨了在Oracle数据库中使用IN子句进行查询时遇到的ORA-01722无效数字错误,并提供了一种解决方案,即通过字符串操作来避免这一问题。
1447

被折叠的 条评论
为什么被折叠?



