select * from table1 where id like '(select subid where CNname='张三')%'
总是有语法错误.
查书也查不到,只好拜托各位了

解决方案 »

  1.   

    你要实现什么操作,看你的意思似乎应该是用
    select * from table1 where id in (select subid from ... where CNname='张三')
      

  2.   

    select subid where CNname='张三'
    from那里去了???????????
      

  3.   

    改成:
    select * from table1 where id like (select  distinct subid FROM table2 where CNname='张三') & '%'
      

  4.   

    select * from table1 where id like (select subid+'%' from table1 where CNname='张三')
      

  5.   

    '(select subid where CNname='张三')%'
    是个查询的值把,如果是这样的话就先把
    string temp="(select subid where CNname='张三')%";select * from table1 where id like temp 试试看
      

  6.   

    select subid where CNname='张三'from ???
      

  7.   

    select * from table1 where id like (select  distinct subid FROM table2 where CNname='张三') & '%'
        这样写语法有错误select * from table1 where id in (select subid from subtable where CNname='张三')
    这样写没有错误但是查不到记录呀
     
    我是想实现 查询到subtable中中文名等于张三的编号,然后再查找table1中以这个编号开头的所有记录。
    是不是很难呀
      

  8.   

    select * 
    from table1 a , subtable b
    where b.CNname='张三' and a.id like b.subid + '%'
      

  9.   

    select * from table1 where id like ((select subid where CNname='张三')+'%')
    这样就可以了
      

  10.   

    还有你
    select subid where CNname='张三'
    子句缺少了from部分
      

  11.   

    同意
    select * 
    from table1 a , subtable b
    where b.CNname='张三' and a.id like b.subid + '%'
      

  12.   

    都不行,只能用笨方法,在SQL语句中首先把表合成一个然后再like
      

  13.   

    做了测试回复人: llldreamnew(花猫) ( ) 信誉:100  2005-04-20 11:26:00  得分: 0  
     
     
       select * 
    from table1 a , subtable b
    where b.CNname='张三' and a.id like b.subid + '%'
      
     
    方法可以
      

  14.   

    select * 
    from table1 a , subtable b
    where b.CNname='张三' and a.id like b.subid + '%'
      
    这个可以