两个表之间的查询

时间:2015-09-27 09:02:45

标签: mysql .net database executereader

这是我的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')"

1 个答案:

答案 0 :(得分:0)

如果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')"