Matt Walmsley
Matt Walmsley

Reputation: 23

How do I find matching data from two tables?

Sorry for the lack of experience in advance.

I have cleansed my diagnostics table and want extract just the rows from followup questions that share the same string in both the AssetType and RepairType columns as the diagnostics table.

Is there a statement or join I can do that will bring back those results?

enter image description here

Upvotes: 0

Views: 48

Answers (1)

Captain Kenpachi
Captain Kenpachi

Reputation: 7215

What you can do is perform an inner join from diagnostics to followupquestions:

SELECT * FROM 
    Diagnostics D
INNER JOIN
    FollowupQuestions F
ON
    D.AssetType = F.AssetType
    AND
    D.RepairType = F.RepairType

An inner join will only return rows where the ON condition is met.

Upvotes: 1

Related Questions