在asp.net core mvc中使用Dapper连接表格并通过多种条件进行过滤。

问题描述 投票:0回答:1

我想查询连接两个有多个条件的表。

  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'."}

jquery sql sql-server asp.net-core dapper
1个回答
0
投票

请使用下面的代码,代码中有一个类型错误,你在贷款表和别名l之间添加了delete dna approve条件。

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 ";
© www.soinside.com 2019 - 2024. All rights reserved.