sql - 在另一个查询中使用查询结果
问题描述
我有 3 张桌子:cc_claim
, cc_exposure
,cc_new
我正在尝试claimID
从cc_claim
by中选择claimNumber
,然后使用它从表ID
中检索 an 。然后最后我想从表中选择具有该. 到目前为止,这是我的代码:exposureID
cc_exposure
cc_new
exposureID
SELECT cc_claim.ID as test
FROM cc_claim
where ClaimNumber ='19D1000011'
JOIN (cc_exposure where AssignedUserID = test)
我不确定我是否走在正确的轨道上.. 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
推荐阅读
- java - 递归合并 2 个已排序的堆栈
- python - 使用自定义 ML 方法进行超参数调整
- c# - 使用 xUnit 和 FakeItEasy 对 Azure 函数 v3 进行单元测试
- oracle - Oracle Apex 图表标签颜色
- angular - Angular 有条件地应用正文样式表
- r - 从具有不同形状的不同光栅文件中提取 RGB 值
- wso2 - WSO2 身份服务器 - 违反密码策略时出现内部错误 18013
- java - log4j 错误 java.lang.NoSuchMethodError: org.apache.log4j.spi.LoggingEvent.getTimestamp()J
- c# - 为什么将项目添加到 ObservableCollection 时我的视图没有更新
- java - int[][] 表示灰度图像,如何将有符号值转换为无符号值