Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Query Table While Excluding Other Table's Matches

5:52 pm on Jun 3, 2013 (gmt 0)

Full Member

10+ Year Member Top Contributors Of The Month

joined:Sept 30, 2009
votes: 1

I have two tables:

id = unique, key
name = place name
neighborhood = neighborhood of the place
city = city of the place
country = country of the place

id = unique, key

Currently I am running a query on the places table:

SELECT * FROM places WHERE (neighborhood="" OR city="" OR country="") LIMIT 5;

How can I modify my query to exclude any rows with their id on the flags table?
7:11 pm on June 3, 2013 (gmt 0)

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
votes: 201

The following should work:
FROM places p LEFT OUTER JOIN flags f ON p.id=f.id
WHERE (p.neighborhood="" OR p.city="" OR p.country="") AND f.id IS NULL

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members