请教一句sql语言,老是说我格式不对,很简单,搞了一晚上,大家帮帮忙!
 sql.add('select count(*) from department where custno in (select custom from customtalbe where Ship='+adoquery1.fieldbyname('Ship').Asstring));
就是引号的问题,我不知道该怎么用引号,查书也没查到,请问有相关资料让我 学习学习吗?非常感谢!

解决方案 »

  1.   

    sql.add('select count(*) from department where custno in (select custom from customtalbe where Ship='+adoquery1.fieldbyname('Ship').Asstring+')');
      

  2.   

    sql.add('select count(*) from department where custno in (select custom from customtalbe where Ship=''' + adoquery1.fieldbyname('Ship').Asstring + ''')');
      

  3.   

    sql.add('select count(*) from department where custno in (select custom from customtalbe where Ship='+adoquery1.fieldbyname('Ship').Asstring+')');
      

  4.   

    lz
    如果你的数据库是access的话就用
    sql.add('select count(*) from department where custno in (select custom from customtalbe where Ship=''' + adoquery1.fieldbyname('Ship').Asstring + ''')');
    如果是ms sql server 2000 就用sql.add('select count(*) from department where custno in (select custom from customtalbe where Ship='+adoquery1.fieldbyname('Ship').Asstring+')');
      

  5.   

    遇到这类问题,如果不想与'号纠缠不清的话,请使用quotedstr函数。sql.add('select count(*) from department where custno in (select custom from customtalbe where Ship='+quotedstr(adoquery1.fieldbyname('Ship').Asstring+')');即可