Solved

mysql single query for two tables

Posted on 2014-02-25
4
269 Views
Last Modified: 2014-02-28
how can i combine the following into one query.
the two tables are unrelated lists of IP addresses, one a whitelist and one a blacklist of IP addresses.   I want to to return nothing IF the IP address  IS ANYWHERE in the whitelist
Thus whitelist takes precedence in the logic, over the blacklist.

SELECT blacklist.* FROM blacklist, whitelist  
         WHERE   blacklist.IPaddress='$IPaddress'
             BUT NULL RESULTS     IF     COUNT(whitelist.IPaddress='$IPaddress')>0

i need to do this within one query due to the way i'm executing it via a single shell command.

thanks
0
Comment
Question by:willsherwood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39887322
What's wrong with And?
SELECT blacklist.* FROM blacklist, whitelist  
         WHERE   blacklist.IPaddress='$IPaddress' AND COUNT(whitelist.IPaddress='$IPaddress')=0

Open in new window


HTH,
Dan
0
 

Author Closing Comment

by:willsherwood
ID: 39887427
i guess nothing's wrong with "thank you" too
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39887448
Glad I could help!
0
 

Author Comment

by:willsherwood
ID: 39896350
please help further - it turns out the COUNT cannot be used in a WHERE clause
"illegal use of GROUP function"

back to original question:   how to include two tables as desired above?
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question