首页 > 解决方案 > 在另一个查询中使用查询结果

问题描述

我有 3 张桌子:cc_claim, cc_exposure,cc_new

我正在尝试claimIDcc_claimby中选择claimNumber,然后使用它从表ID中检索 an 。然后最后我想从表中选择具有该. 到目前为止,这是我的代码:exposureIDcc_exposurecc_newexposureID

SELECT cc_claim.ID as test
FROM cc_claim
where ClaimNumber ='19D1000011'
JOIN (cc_exposure where AssignedUserID = test)

我不确定我是否走在正确的轨道上.. sql 新手。

标签: sql

解决方案


我想这可能是你的想法:

SELECT c.ID AS test
FROM cc_claim c
INNER JOIN cc_exposure ex
    ON c.ID = ex.AssignedUserID
WHERE c.ClaimNumber = '19D1000011';

请注意,它JOIN总是在子句之后 FROM和之前。WHERE


推荐阅读