Mysql Like %..% operator
#1

is there a way of using Like % operator via samp query ?

this is what im talking about

Reply
#2

I have no idea what 'LIKE %...%' is. If you could explain what it does maybe I can help
Reply
#3

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%'
Reply
#4

Yes, you can. Insert % twice like "%%" to format a % symbol. Check "Format Specifiers" - https://sampwiki.blast.hk/wiki/Format
Reply
#5

Quote:
Originally Posted by Lordzy
View Post
Yes, you can. Insert % twice like "%%" to format a % symbol. Check "Format Specifiers" - https://sampwiki.blast.hk/wiki/Format
Thanks alot
Reply
#6

Quote:
Originally Posted by BlowUP
View Post
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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)