Forum Moderators: open

Message Too Old, No Replies

need inverse of this query

mysql

         

sasori

11:51 pm on Jul 15, 2009 (gmt 0)

10+ Year Member



hello,
I have a query that works correctly, but I need the result to be inversed:
SELECT DISTINCT states.stid,
states.name AS state_name
FROM states, new_contact
WHERE states.stid = new_contact.state

states.* contains all of the states.
right now, this generates a list of states that are already in new_contact.state. I need the list to be of states not in new_contact.state.

Can anyone help?

Thanks!

LifeinAsia

3:31 pm on Jul 16, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Try:
SELECT DISTINCT states.stid,
states.name AS state_name
FROM states LEFT OUTER JOIN new_contact ON states.stid = new_contact.state
WHERE new_contact.state IS NULL

sasori

5:04 pm on Jul 16, 2009 (gmt 0)

10+ Year Member



perfect!

Thanks!