Mysql Like %..% operator - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql Like %..% operator (
/showthread.php?tid=593421)
Mysql Like %..% operator -
BlowUP - 05.11.2015
is there a way of using Like % operator via samp query ?
this is what im talking about
Re: Mysql Like %..% operator -
jeffery30162 - 05.11.2015
I have no idea what 'LIKE %...%' is. If you could explain what it does maybe I can help
Re: Mysql Like %..% operator -
BlowUP - 05.11.2015
http://www.tutorialspoint.com/sql/sql-like-clause.htm
used to compare a value to similar values just like strcmp
pawn Code:
` WHERE `ip` LIKE '127.0.0.1'
but with LIKE % i can find ip's starting with 127.0 only example
pawn Code:
SELECT * FROM `banz` WHERE `ip` LIKE '%127.0%'
Re: Mysql Like %..% operator -
Lordzy - 05.11.2015
Yes, you can. Insert % twice like "%%" to format a % symbol. Check "Format Specifiers" -
https://sampwiki.blast.hk/wiki/Format
Re: Mysql Like %..% operator -
BlowUP - 05.11.2015
Quote:
Originally Posted by Lordzy
|
Thanks alot
Re: Mysql Like %..% operator -
Vince - 05.11.2015
Quote:
Originally Posted by BlowUP
but with LIKE % i can find ip's starting with 127.0 only example
|
Since you explicitly mention IPs, consider saving them in integer format because this gives you additional possibilities to search. You can do:
PHP Code:
... WHERE ip BETWEEN INET_ATON('172.16.0.0') AND INET_ATON('172.31.255.255');
Which would be shear impossible to accomplish with LIKE. See
my tutorial for a more elaborate explanation.