Skip to content
Advertisement

TSQL Two different tables, 800GB vs 2GB Find common

I have two tables, generatedblock table, and addresses table The generatedblock table has a column called expandedblock block. The addresses table has a column called address. What I need to do is find if in the generatedblock table there is a value in the addresses table.
I have tried failed code but I am not reposting because my tsql sucks, How do I check every row in the address table, or visi versa contains a value, and to list the value in a temp table.

table generatedblock column expandedblock
-------------
1234
2334
4567
9878
4353
2345
3456

table addresses column address
-------------
1111
2222
3333
4444
5555
6666
1234

i get result return more than 1 row and I want those rows

SELECT * 
FROM generatedblock
WHERE ExpandedBlock in (SELECT DISTINCT address FROM addresses)

Advertisement

Answer

You might be looking for INNER JOIN:

SELECT * 
FROM generatedblock A
INNER JOIN address  B
    ON A.ExpandedBlock = B.address;
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement