sql - INNER JOIN with a large table -


i using microsoft access 2013, , trying join table1 , table2 together, problem table2 massive. table1 list of part, vendor combinations pk part, vendor. table2 table created top2 recent quotes each part,vendor combination. these quotes pulled table pk quote_id. think creation of table2 might problem, because cannot create table2 every part,vendor combination (i have filter out vendor). query used table2.

a.part, a.vendor, a.quote_date quotetable  a.quote_date > dateadd("yyyy", -3, date()) ,  a.quote_date in   (select top 2 quote_date   quotetable   quote_date > dateadd("yyyy", -3, date()) ,   part=a.part  , vendor=a.vendor   order quote_date desc) 

if knows better way select top 2 recent quotes table each part,vendor combination, appreciate it. join, works take long.

select * table1 inner join table2 b on a.id = b.id 

i wondering if there way use id table1 filter table2? this:

select *  table1 inner join    (select * table2 id=a.id) b on a.id = b.id 

you use:

select *  table1  inner join (select * table2 id=a.id) b  on a.id = b.id 

or use :

with cte ( select *  table2  id in (select id table1) ) select *  table1  inner join cte  on cte.id = a.id 

for performance issue, try create index on id column both tables, or try limit selected column result.


Comments