Eric,
Friday, November 15, 2002, 1:36:54 AM, you wrote:

EA> Assume two tables:

EA> CREATE TABLE block_ip (
EA>   datestamp int(11) NOT NULL default '0',
EA>   remote_addr char(15) NOT NULL default '',
EA>   PRIMARY KEY  (remote_addr),
EA>   KEY datestamp (datestamp)
EA> ) TYPE=MyISAM;

EA> CREATE TABLE brute_force (
EA>   datestamp int(11) NOT NULL default '0',
EA>   remote_addr char(15) NOT NULL default '',
EA>   remote_user char(35) NOT NULL default '',
EA>   KEY remote_addr (remote_addr),
EA>   KEY datestamp (datestamp),
EA>   KEY remote_user (remote_user)
EA> ) TYPE=MyISAM;

EA> Contents of the 'brute_force' table (remote_addr):

EA> 1.2.3.4
EA> 2.3.4.5
EA> 3.4.5.6
EA> 4.5.6.7
EA> 5.6.7.8
EA> 6.7.8.9

EA> Contents of the 'block_ip' table (remote_addr):

EA> 2.3.4.5
EA> 4.5.6.7

EA> Can someone help me with the query that will select all the
EA> 'remote_addr' rows from 'brute_force' that are NOT in the 'block_ip'
EA> table?

EA> Something like:

EA> select brute_force.* from brute_force, block_ip where
EA> brute_force.remote_addr != block_ip.remote_addr

EA> maybe?  I have a feeling it's some sort of left join, and I was never
EA> very good at those.  :-/

Yes, you need LEFT JOIN :)

SELECT brute_force.* FROM brute_force
LEFT JOIN block_ip ON brute_force.remote_addr=block_ip.remote_addr
WHERE block_ip.remote_addr IS NULL;



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com





---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to