By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

SQL JOIN query - Inner, Left or Right?

P: n/a
I need to insert into a persistent table all the various ParameterIDs that
are found in a linked table but not already in the persistent table.
Starting with a Select query, I thought it might look like this:

SELECT DISTINCT ParameterID
FROM tblLinked INNER JOIN tblParameter ON tblLinked.ParameterID <>
tblParameter.ParameterID;

Ideally, I'd like to use an Append query that just sucks into tblParameter
any ParameterID found in tblLinked that's not already in tblParameter. Is
this a job for a Left Join?

INSERT INTO tblParameter SELECT DISTINCT tblLinked.ParameterID FROM
tblLinked LEFT JOIN tblParameter ON tblLinked.ParameterID <>
tblParameter.ParameterID;

I'm trying to avoid a nested select in the interest of speed (the query is
in a loop). So I want to avoid this:

INSERT INTO tblParameter SELECT DISTINCT tblLinked.ParameterID FROM
tblLinked WHERE tblLinked.ParameterID Not In (SELECT ParameterID FROM
tblParameter);

but that shows what I'm trying to do.

Can I use an Append query with a Join statement to accomplish this?

Thanks in advance.
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
aren't you essentially doing a Find Unmatched and then turning that
into an append query?

So you left join the tables on the field that might be null, filter for
the nulls and turn that into an append query. No NOT IN slowness
required.

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.