"参数太少,预计1"在MS Access 2000中使用WHERE子句时

时间:2015-03-14 18:59:16

标签: sql database where-clause ms-access-2000

我有一些MS Access查询字符串可以正常工作,但如果我将此字符串添加到WHERE子句:

$sqlCond = "c_land.land='CZ' AND left(c_kunde.nr,1)<>'E'";

我收到错误:

  

参数太少。预期1.,SQLExecDirect中的SQL状态07001 ...

完整查询是:

$SQL = "SELECT nr, name1, plz FROM c_kunde WHERE db='G' AND 
        (firma_typ='D' OR firma_typ Is null) AND 
        len(name1)>0 AND name1<>'?' AND ".
        $sqlCond.
        " ORDER BY name1";

有什么不对吗?


解: 根据@Maciej Los评论,我添加了INNER JOIN并修改了这样的sql字符串,现在它可以工作:

$SQL = "SELECT c_kunde.nr, name1, plz, c_land.land FROM c_kunde 
        INNER JOIN c_land ON c_kunde.id_land = c_land.nr WHERE db='G' AND 
        (firma_typ='D' OR firma_typ Is null) AND 
        len(name1)>0 AND name1<>'?' AND ".
        $sqlCond.
        " ORDER BY name1";

0 个答案:

没有答案