两表间查询
Query between two tables
这是我的带有 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
是您的 table 名称(带空格),它应该用反引号括起来,如下所示:
`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')"
这是我的带有 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
是您的 table 名称(带空格),它应该用反引号括起来,如下所示:
`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')"