AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQL_PrepareQuery and "LIKE '%%s%'" (https://forums.alliedmods.net/showthread.php?t=74500)

Nepopus 07-19-2008 21:41

SQL_PrepareQuery and "LIKE '%%s%'"
 
Hello, I have faced such problem:
I wish to get from a database a name of the player, not equal value, but like as.
Directly from a database it looks so: (My nick name is nepopus)
SELECT pp.name FROM ps_plr_profile as pp WHERE pp.name LIKE '%epopu%' ORDER BY pp.name ASC LIMIT 1
in .sma file I entered:
new uniqueid[32]
new fmt[1024]
format(uniqueid, 31, "epopu")
format (fmt, 1023, " SELECT pp.name FROM ps_plr_profile as pp WHERE pp.name LIKE '%%s%' ORDER BY pp.name ASC LIMIT 1 ", uniqueid)
new Handle:rquery = SQL_PrepareQuery (sqlconnect, fmt)
and in game i got a error with "LIKE='%%s%'", how can i do it with '%', '%', but w/o error :)
huh... i hope you will understand my eng
P.S. its last step for my first version ingame rank system for psychostats, and ill post it when remove this error

Hawk552 07-19-2008 21:54

Re: SQL_PrepareQuery and "LIKE '%%s%'"
 
"%%" gets escaped to "%".

Nepopus 07-19-2008 22:28

Re: SQL_PrepareQuery and "LIKE '%%s%'"
 
Quote:

Originally Posted by Hawk552 (Post 655347)
"%%" gets escaped to "%".

And where is the decision?:wink:
cuz i need only "LIKE '%epopu%'" at finish, like as in database :(

XxAvalanchexX 07-19-2008 22:32

Re: SQL_PrepareQuery and "LIKE '%%s%'"
 
So just do %%epopu%%, or %%%s%% (in the SMA).

Nepopus 07-19-2008 22:57

Re: SQL_PrepareQuery and "LIKE '%%s%'"
 
Quote:

Originally Posted by XxAvalanchexX (Post 655358)
So just do %%epopu%%, or %%%s%% (in the SMA).

no error, but wasn't found nepopus as "LIKE '%%%s%%'" (%s = epopu). only find my name as nepopus(not epopu) :)
huh, It is very complex to me to express an idea :)
i think i need to write '%' as another symbol, but dunno how to do this
sorry my fault, dont need to format, search ftw :) http://forums.alliedmods.net/showthr...ght=%25%25s%25


All times are GMT -4. The time now is 05:35.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.