日期:2014-05-17  浏览次数:21062 次

这样的脚本在Oracle中为什么就不能执行?
SELECT   *   FROM   TableName  
where   '   10,   11,   13,   12,   40,   47,   48,   49,   90,   92,   91,   94,   95,   96,   30,   31,   33,   34,   35,   24,   20,   21 '   like   '%   '+menuid+ ',% '   order   by   menuid  
上面这段我在MS   SQL中可以正常执行,但放到oracle中就提示无效数字错误,上面这句语句在Oracle中应该怎么写?menuid是表TableName中的一列,里面的记录内容就可能是10或11....

------解决方案--------------------
在oracle中:

SELECT * FROM TableName
where munuid in (10,11,13,12,40,47,48,49,90,92,91,94,95,96,30,31,33,34,35,24,20,21 ') order by menuid;



------解决方案--------------------
CREATE TABLE ta(menuid VARCHAR2(20),aaa VARCHAR2(20))

oracle中连接用||
INSERT INTO ta
SELECT '10 ', 'aa ' FROM dual
UNION
SELECT '20 ', 'bb ' FROM dual
UNION
SELECT '30 ', 'bb ' FROM dual
UNION
SELECT '11 ', 'bb ' FROM dual
UNION
SELECT '210 ', 'bb ' FROM dual


SELECT * FROM ta
WHERE ' 10, 11, 13, 12, 40, 47, 48, 49, 90, 92, 91, 94, 95, 96, 30, 31, 33, 34, 35, 24, 20, 21 '
LIKE '% '||TO_CHAR(menuid)|| ',% ' ORDER BY menuid
------解决方案--------------------
oracle连接符是||,不是+