我遇到了一个问题,使用“IN”运算符从另一个数据库获取数据。我需要帮助解决这个问题。
我的查询如下所示:
SELECT i.EXTERNAL_CODE, tc.SITE_NAME, tr.TRANSACTION_DT
FROM app4_starlims_data.dbo.INVENTORY i
JOIN app4_starlims_data.dbo.VA_TUBE_COLLECTION tc
ON tc.INVENTORYID = i.INVENTORYID
JOIN app4_starlims_data.dbo.INVENTORY_TRANSACTIONS it
ON it.INVENTORYID = i.INVENTORYID
JOIN app4_starlims_data.dbo.transactions tr
ON tr.TRANSACTION_ID = it.TRANSACTION_ID
WHERE i.EXTERNAL_CODE IN
(SELECT vacutainer_ref, quality, [timestamp]
FROM dna_lab_biospecimen.dbo.blood_sample
WHERE quality LIKE '%under%'
AND [timestamp] BETWEEN '02-19-2021' AND '03-07-2021')
我得到的错误是:
查找错误 - SQL Server 数据库错误:当 EXISTS 未引入子查询时,选择列表中只能指定一个表达式。