MS ACCESS SQL Join Subquery -
i have 2 tables: newparts, storedparts
i insert parts of newparts, not jet in storedparts storedparts:
sql_string = "insert storedparts " & _ "select newparts.* " & _ "from storedparts " & _ "right join newparts on (storedparts.identifier = newparts.identifier) , (storedparts.timestamp = newparts.timestamp) " & _ "where ((storedparts.autoid) null);"
this working fine far. problem: table storedparts getting big programm taking long join process. solution: compare newparts not parts of storedparts, parts aren't older 4 days... tried subquery this, can't run.
sql_string = "insert storedparts " & _ "select newparts.* " & _ "from storedparts (where storedparts.timestamp > now() - 4) " & _ "right join newparts on (storedparts.identifier = newparts.identifier) , (storedparts.timestamp = newparts.timestamp) " & _ "where ((storedparts.autoid) null);"
any appreciated.
this wouldn't problem if tables have indexes.
create index ndx_sp_identifier on storedparts (identifier); create index ndx_np_identifier on newparts (identifier);
then suggest change query @jarlh pointed out.
insert storedparts select newparts.* newparts left join storedparts on newparts.identifier = storedparts.identifier , newparts.timestamp = storedparts.timestamp storedparts.autoid null;
Comments
Post a Comment