Groups | Blog | Home
all groups > sql server (alternate) > october 2006 >

sql server (alternate) : SQL Query return unused values


Chicagoboy27
10/17/2006 8:30:01 AM
I have a table. In the table I have different types of mailing
addresses. The addresses are linked by and ID. ex,

addresses per ID 1
ID address
1 add2
1 add3
1 add4

distinct Addresses in table
ID address
1 add2
1 add3
1 add4

What I am trying to figure out is if this is possible. Is it possible
to figure out some how with a query that in the above example ID 1
is missing add1. I am trying to populate a dropdown list in my code
with just the addresses that are left from the distinct list. I tried
doing an intersect something like this but that did not seem to work.

SELECT type
FROM address_demo
INTERSECT
SELECT type
FROM address_demo AS address_demo_1
WHERE progid = '12954892'

I am wondering if I am moving in the right direction or if this is even
possible......

Thanks
Chicagoboy27
10/17/2006 9:11:37 AM
i think i might have found a solution that works

SELECT DISTINCT id
FROM address_demo
WHERE (id NOT IN
(SELECT type
FROM address_demo AS
address_demo_1
WHERE (id = @ID)))
ORDER BY type

[quoted text, click to view]
AddThis Social Bookmark Button