寻找正确的语法,了解如何获取在主数据库中执行“NOT EXISTS”但在远程数据库中执行的所有记录
以下代码从远程数据库获取所有空白记录,不确定它是否与本地数据库有关。
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="<%$ ConnectionStrings:accessConnectionString %>"
SelectCommand="SELECT EnrollmentsTbl.UserName, EnrollmentsTbl.SubmitTime, EnrollmentsTbl.ClassName,
EnrollmentsTbl.ClassDate, EnrollmentsTbl.ClassTime, EnrollmentsTbl.Enrolled, EnrollmentsTbl.WaitListed, EnrollmentsTbl.Instructor,
EnrollmentsTbl.DateCompleted, EnrollmentsTbl.Completed, EnrollmentsTbl.Walkin
FROM [;DATABASE=e:\subsite.mdb].EnrollmentsTbl AS XXX
LEFT JOIN EnrollmentsTbl ON XXX.UserName = EnrollmentsTbl.UserName WHERE (EnrollmentsTbl.UserName Is Null)">
</asp:AccessDataSource>
答案 0 :(得分:2)
&#34;标准&#34;方法是使用外连接并对空值进行过滤,将其解释为:
select r.*
from remote_table r
left join local_table l
on l.id = r.id
where l.id is null
答案 1 :(得分:0)
这是最终的解决方案:
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="<%$ ConnectionStrings:accessConnectionString %>"
SelectCommand="SELECT XXX.UserName, XXX.SubmitTime, XXX.ClassName,
XXX.ClassDate, XXX.ClassTime, XXX.Enrolled, XXX.WaitListed, XXX.Instructor,
XXX.DateCompleted, XXX.Completed, XXX.Walkin
FROM [;DATABASE=e:\subsite.mdb].EnrollmentsTbl AS XXX
LEFT JOIN Users ON XXX.UserName = Users.UserName WHERE (Users.UserName Is Null)">
</asp:AccessDataSource>