在asp.net核心mvc中使用dapper连接表并按多个条件过滤

nhhxz33t  于 2021-07-29  发布在  Java
关注(0)|答案(1)|浏览(362)

我想用多个条件查询联接两个表

string sql = "Select l.*, c.FirstName_CompanyName from dbo.Loan l left join Customer c on  l.CustId=c.CustId where LoanAccountNo > 0 ";

当我实现上面的代码,但我发现我需要过滤贷款表批准和删除,但我似乎不能得到它的权利。
下面的代码是我尝试过但不起作用的代码

string sql = "Select l.*, c.FirstName_CompanyName from dbo.Loan WHERE Delete = 0 AND Approve = 1 l left join Customer c on  l.CustId=c.CustId where LoanAccountNo > 0 ";
{"Incorrect syntax near the keyword 'Delete'."}
1tu0hz3e

1tu0hz3e1#

请使用下面的代码,代码中存在类型错误,您在贷款表和别名l之间添加了删除dna批准条件

string sql = "Select l.*, c.FirstName_CompanyName from dbo.Loan l WHERE l.Delete = 0 AND l.Approve = 1 left join Customer c on  l.CustId=c.CustId where LoanAccountNo > 0 ";

相关问题