我正在编写如下 SQL 查询:
ALTER proc [dbo].[Invoice_GetHomePageInvoices] (
@AreaIdList varchar(max)
, @FinancialYearStartDate datetime = null
, @FinancialYearEndDate datetime = null
) as
set nocount on
select *
from Invoice i
left outer join Organisation o on i.OrganisationId = o.Id
left outer join Area a on i.AreaId = a.Id
where i.InvoiceDate BETWEEN @FinancialYearStartDate AND @FinancialYearEndDate
@AreaIdList 参数将采用“1,2,3”等格式。
我想添加一条仅返回区域 id 等于@AreaIdList 中任何 id 的发票的行。
如果在 areaId 上搜索 ie,我知道如何做一个声明。现在问题出在哪里i.AreaId == areaId
我有这个列表,我要比较@AreaIdList 中的每个区域 ID。
谁能告诉我你会怎么做?