question

nikhilgupta1891 avatar image
nikhilgupta1891 asked

Find a matching column in 2 tables - Optimized way

I have 2 SQL tables that have a matching column - ID. ID is the primary key in both tables.

Table1: ID, field1, field2, ... field n
Table 2: ID, fieldx, fieldy..... filed z

Both tables have around 400k-600k rows. I want to get the list of ID's from Table2 that matches with Table1 in the most optimized way. Brute force way of matching row-by-row would be very slow.


Please suggest an optimal/lesser time-complexity solution.

search
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

So you want where table1.Id = table2.id


or are you trying to find table1.field1 = table2.field1 or table2.field2 or table2.field3?

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.