-
SQL Help - urgent
Hi,
I need an urgent help in writing an sql command. I have a combo box in which I need to write a query to fill it with mailboxnames(one of the fields in let us say Table1). But the catch is that I have another table (let us say Table2) which also has mailboxnames as one of its fields. The query should include only those mailboxnames from Table1 which are not present in Table2.
Something like
INSERT Mailboxnames from Table1 WHERE Table1.MailboxNames <is not present in> Table2.MailboxNames
Thanks, any help would be greatly appreciated.
-
Re: SQL Help - urgent
You could left join and only insert those that return null in table 2.
Or you could use 'exists' or 'not exists' (you will need to read up on them) but the general gist is that you can supply a select statement in the exists part to look for those which exist (or don't) in the other table.
Isn't the syntax:
Code:
INSERT INTO <table> (<fields>)
SELECT <tables and fields>
FROM <tables / joins>
-
Re: SQL Help - urgent
Right, thanks ecniv. I got the Left Join solution.