Skip to content
Advertisement

SQL inner join on column A and compare values in column B

I am sure or maybe hope there is a simple way to do this. Below is my latest attempt. The query should return only one row, but I get 31.

Query:

Table Data:

Table A

EC CERS EC Tank ID
100338 1
100338 2
100338 3

Table B

CIW CERS CIW Tank ID
100338 001
100338 2
100338 3

Table Schema

I need the query to return one row preferably showing the EC CERS, EC Tank ID and CIW Tank ID.

Advertisement

Answer

if it is the matter of leading ziros , you can go with this solution:

this is not going to work if you have non-numeric in your Ids

actually another solution is to show the ones that you can’t find a match:

if you want to show non-matched cases side by side, you have to go from both side and find non-matching instances :

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement