Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,242 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,227 people online right now. Registration is fast and FREE... Join Now!




SQL Statement: How to select all from table1 where table1.a doesnt exi

 
Reply to this topicStart new topic

SQL Statement: How to select all from table1 where table1.a doesnt exi

Coisox
11 Oct, 2008 - 09:48 AM
Post #1

New D.I.C Head
*

Joined: 10 Oct, 2008
Posts: 4

Hi, I'm using Vb.net 2008 and MS Access. I'm not sure whether it is possible or not. Lets say:

Table1: Name, Address, Phone
Table2: Name, Hobby, Income

I need SQL statement to select all records in Table1 where the name doesn't exist in Table2.

Something like this:
CODE
dataAdapter = New OleDb.OleDbDataAdapter("SELECT * From Table1 WHERE Table1.name <> Table2.name, cnADONetConnection)

User is offlineProfile CardPM
+Quote Post

magicmonkey
RE: SQL Statement: How To Select All From Table1 Where Table1.a Doesnt Exi
11 Oct, 2008 - 11:32 AM
Post #2

D.I.C Regular
***

Joined: 12 Sep, 2008
Posts: 413



Thanked: 68 times
My Contributions
Im not sure if access supports sub queries, been too long since I have used it, but in SQL you could do...

CODE

"SELECT * From Table1 t1 WHERE T1.name not in (Select t2.name from table2 t1)"



User is offlineProfile CardPM
+Quote Post

rollout369
RE: SQL Statement: How To Select All From Table1 Where Table1.a Doesnt Exi
17 Oct, 2008 - 04:00 AM
Post #3

New D.I.C Head
*

Joined: 17 Oct, 2008
Posts: 6

Sometimes it's best to try to create a query in Access to do what you want and then just call the query from your program. If you can get the Access query working then you're set--this can save a lot of programming time.
User is offlineProfile CardPM
+Quote Post

Coisox
RE: SQL Statement: How To Select All From Table1 Where Table1.a Doesnt Exi
17 Oct, 2008 - 04:41 AM
Post #4

New D.I.C Head
*

Joined: 10 Oct, 2008
Posts: 4

QUOTE(rollout369 @ 17 Oct, 2008 - 05:00 AM) *

Sometimes it's best to try to create a query in Access to do what you want and then just call the query from your program. If you can get the Access query working then you're set--this can save a lot of programming time.

Oh, this is better. Thx for the advice. So now I just use the MS Access query wizard then copy paste into my programming smile.gif

magicmonkey: The SQL generated by the MS Access wizard does use sub queries. Thank you for your time.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:46AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month