select gid 
from t_grp_org 
where nodepath like '%(select gid from t_grp_org where gname = '北京')%'
错误提示ORA-00907:缺少右括号问题sql如上,
我的解析如下
(select gid from t_grp_org where gname = '北京')结果正常为657232select gid 
from t_grp_org 
where nodepath like '%657232%')则结果正常所以我分析是sql执行顺序导致,希望能够调节格式实现

解决方案 »

  1.   

    select gid  
    from t_grp_org  
    where nodepath like '%'|| (select gid from t_grp_org where gname = '北京' and rownum=1) ||'%' 
      

  2.   

    select gid  
    from t_grp_org  
    where nodepath like '%'+(select gid from t_grp_org where gname = '北京')+'%'刚试了下,这样没问题
      

  3.   

    select gid  
    from t_grp_org  
    where nodepath like '%'|| (select gid from t_grp_org where gname = '北京' and rownum=1) ||'%'
      

  4.   

    select gid  
    from t_grp_org  
    where nodepath like '%' || (select gid from t_grp_org where gname = '北京') || '%'select m.gid  
    from t_grp_org m , (select gid from t_grp_org where gname = '北京') n
    where m.nodepath like '%' || n.gid || + '%'select m.gid  
    from t_grp_org m , (select gid from t_grp_org where gname = '北京') n
    where instr(n.gid , m.nodepath) > 0
      

  5.   

    使用Oracle示例数据库验证如下:SELECT employee_id, first_name
    FROM employees 
    WHERE first_name LIKE '%' || (SELECT first_name FROM employees WHERE employee_id = 1) || '%';
    结果正常。
      

  6.   

    select gid   
    from t_grp_org   
    where nodepath like '%' || (select gid from t_grp_org where gname = '北京') || '%'变量与常量之间用 || 进行连接