Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: (OT) mysql regexp unwanted matches for specific IP

by McDarren (Abbot)
on Jan 30, 2013 at 12:07 UTC ( #1016047=note: print w/ replies, xml ) Need Help??


in reply to (OT) mysql regexp unwanted matches for specific IP

If you're looking for a specific IP address, then why bother messsing around with a pattern match?

I mean, what's wrong with:

select * from table where field like '%10.100.1.1%';

P.S. This is a Perl site, not a MySQL site ;-)


Comment on Re: (OT) mysql regexp unwanted matches for specific IP
Download Code
Re^2: (OT) mysql regexp unwanted matches for specific IP
by hippo (Curate) on Jan 30, 2013 at 14:41 UTC

    Almost there, but to match the OP's criteria you'll need an extra whitespace, so assuming the address is the first string in the field:

    select * from table where field like '10.100.1.1 %';

    It still has nothing to do with Perl, though.

Re^2: (OT) mysql regexp unwanted matches for specific IP
by kp2a (Sexton) on Jan 30, 2013 at 14:46 UTC
    because
    mysql> select state,d09,d07 from service where d07 like '%10.100.1.1%' +; +-------+--------------------------+--------------+ | state | d09 | d07 | +-------+--------------------------+--------------+ | 0 | cr1.pullpnt 25512 | 10.100.1.158 | | 0 | Link PP2Prn 25506 | 10.100.1.157 | | 0 | Link PP2Sol 25505 | 10.100.1.130 | | 0 | CV2SOL 26754 | 10.100.1.138 | | 0 | Link Sol2CV 26775 | 10.100.1.139 | | 0 | Link Sol2PP 27014 | 10.100.1.131 | | 0 | Link Princess2Pull 27016 | 10.100.1.154 | | 0 | br1.glbx 28281 | 10.100.1.1 | +-------+--------------------------+--------------+ 8 rows in set (0.02 sec)
    but I tried - thanks suggestion -
    mysql> select state,d09,d07 from service where d07 like '%10.100.1.1'; +-------+----------------+------------+ | state | d09 | d07 | +-------+----------------+------------+ | 0 | br1.glbx 28281 | 10.100.1.1 | +-------+----------------+------------+ 1 row in set (0.02 sec)
    yes, I know perl site - a lot of wise monks - and regexp experts - tried mysql sites no help now you regexp experts, why the unexpected regexp behavior? is there something to learn here other than when to use regexp v. like?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016047]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-12-26 00:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls