|
-
Aug 14th, 2005, 08:50 PM
#1
Thread Starter
Member
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.
-
Aug 15th, 2005, 02:42 AM
#2
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>
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 15th, 2005, 02:49 AM
#3
Thread Starter
Member
Re: SQL Help - urgent
Right, thanks ecniv. I got the Left Join solution.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|