这是我的查询与2个参数。有人可以帮帮我吗?

sql = "select *
       from studentlist
       where firstname like '%"
     & Transaction.SEARCHSTUDENT.Text
     & "%' or studentnum like '%"
     & Transaction.SEARCHSTUDENT.Text
     & "%' and not in (select studentnum from borrowing of books where status ='borrowed')"

最佳答案

如果borrowing of books是您的表名(带有空格),则应使用反引号将其括起来,如下所示:

`borrowing of books`


编辑:此外,您的where子句中似乎缺少了studentnum,因此它实际上应如下所示:

sql = "select *
   from studentlist
   where (firstname like '%"
 & Transaction.SEARCHSTUDENT.Text
 & "%' or studentnum like '%"
 & Transaction.SEARCHSTUDENT.Text
 & "%') and studentnum not in (select studentnum from `borrowing of books` where status ='borrowed')"

09-16 04:47