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

Advanced Query Help (DISTINCT)

P: 12
Hi,

I am attempting to query a table and I am not exactly sure how to accomplish this. In my table I have three columns: ID, source, target.

[ID] [source] [target]
1 pa ny
2 pa ca
3 pa pa
4 la pa
5 la ca

How would I write or find help on writing a query that returned only where pa is in the source only, target only, or both (the first 4 IDs)? ID#3 should not occur twice.
Jan 4 '08 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,419
I'm afraid this (as specified) is probably more straightforward than you anticipated.
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM [YourTable]
  3. WHERE (([Source]='pa') OR ([Target]='pa'))
Jan 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.