0

I have 3 tables: cc_claim, cc_exposure, cc_new

I am trying to select the claimID from cc_claim by claimNumber and then use that ID to retrieve an exposureID from the cc_exposure table. Then finally I want to select the column from cc_new table that has that exposureID. Here is my code so far:

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

I am not sure if I am on the right track.. new to sql.

1
  • 3
    Sample data, desired results, and an appropriate database tag would help. Commented Apr 16, 2019 at 15:04

2 Answers 2

3

I think this might be what you had in mind:

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

Note that JOIN always comes after FROM, and before the WHERE clause.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks... what I'm trying to do is grab a value called AssignedUser from the cc_exposure table after I join the table by claimnumber. Is that possible?
@iceMan33 what you are trying to do is still unclear because you did not post all the info needed: column names for all the tables involved and column references for each table, as well as sample data and expected results.
0

you need to join the tables on the matching Ids to get what you need.

 SELECT cc_claim.ID as test,new.exposureId
    FROM cc_claim c
    Inner JOIN cc_exposure ex
        ON c.ID = ex.AssignedUserID
    Inner JOIN  cc_new new
     ON ex.exposureId=new.exposureID

    where c.ClaimNumber ='19D1000011'

1 Comment

While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.