第一条:select * from sys_menu t where t.menu_id in (select a.s_role_id from sys_user_role a where a.user_id='111111');
第二条:select * from sys_menu t where t.menu_id in ('001001','001002','001003','002001','002002','002003','002004','003001','003002','003003','004001','004002','004003','004004','004005','004006001','004006002','004006003','004007001','004007002');
select a.s_role_id from sys_user_role a where a.user_id='111111';的结果是'001001','001002','001003','002001','002002','002003','002004','003001','003002','003003','004001','004002','004003','004004','004005','004006001','004006002','004006003','004007001','004007002'为什么第二条能查到数据,而第一条就查不到数据?

解决方案 »

  1.   

    字段menu_id,s_role_id 类型是什么  是否会有空格?
      

  2.   

    两边字段找一下,length 查一下,是否有不是 6位数字长度的
      

  3.   


      一个空格也是一个长度 有时候数据里面会多出空格 那样查询会查询不到 LZ试下这样
    select * from sys_menu t where trim(t.menu_id) in (select trim(a.s_role_id) from sys_user_role a where a.user_id='111111')
      

  4.   

    未发现有什么问题
    我有这样的猜测:menu_id和s_role_id其中之一是char,另一个是varchar2,即便都是varchar2,也有其中一个是从char改过来的。
    不知猜测是否正确?可以看一下
      

  5.   

    有没有可能是你存储SQL语句变量的长度不够长,造成的。
      

  6.   

    你sys_user_role表的s_role_id列是不是有空值?