Match sql tables to find same values?

I have a table A and table B right.

How can I check if table B column B.B contains values from table A column A.A and output those that don’t match from table A?

SELECT tableB.columnB
  FROM tableB
  LEFT OUTER JOIN tableA ON tableB.columnB = tableA.columnA
 WHERE tableA.columnA IS NULL

Amazing thanks so much. Please one more thing! The table B column B.B contains values like this: hello-world is there a way to remove or skip dashes durring matching?

if you want to replace them with spaces, you could do. If you want to replace it with something else, change that last quoted value.

NOTE : this is only in the returned values. If you want to eliminate them before comparing to tableA, you’ll have to do that on the join, which could get ugly…

SELECT REPLACE(tableB.columnB, "-", " ") AS columnB

That will alter the values for ever but I only want this once! What do you thiknk?

Huh? What do you mean it will alter it forever? The table will still have the dashes in them, you just wouldn’t see them in the returned value from the select.

OH I see buddy I though it was Update but it’s Select.

Thanks so much you are my savor!

Seems like can’t make it work.

How do I add this: SELECT REPLACE(tableB.columnB, “-”, " ") AS columnB to this query: SELECT tableB.columnB
FROM tableB
LEFT OUTER JOIN tableA ON tableB.columnB = tableA.columnA
WHERE tableA.columnA IS NULL

To strip dashes before matching?

Like I said, you’ll have to put it on the JOIN

SELECT tableB.columnB
  FROM tableB
  LEFT OUTER JOIN tableA ON REPLACE(tableB.columnB, "-", "") ON REPLACE(tableA.columnA, "-" "")
 WHERE tableA.columnA IS NULL
1 Like

Thanks so much!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.