Оператор LIKE в запросе
#1

Добрый день!
Как можно послать запрос в БД с оператором LIKE?
Код:
mysql_format(connects,mysqlquery, sizeof(mysqlquery), "SELECT * FROM `connect` WHERE `Name` LIKE '%%e%'",tmp);
mysql_function_query(connects,mysqlquery,true,"GetPlayerMySQLID","d",playerid);
Выводит в mysql log
Код:
[13:51:02] [ERROR] mysql_format - invalid format specifier "%'"
[13:51:02] [ERROR] CMySQLQuery::Execute[GetPlayerMySQLID(d)] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''%s' at line 1
Reply
#2

mysql_format(connects,mysqlquery, sizeof(mysqlquery), "SELECT * FROM `connect` WHERE `Name` LIKE '%e%'",tmp);
mysql_function_query(connects,mysqlquery,true,"Get PlayerMySQLID","d",playerid);
Reply
#3

Я просто сделал подобный запрос в БД Там нужно LIKE `NAME` = '%Dmitry%'
Reply
#4

pawn Код:
mysql_format(connects,mysqlquery,sizeof(mysqlquery),"SELECT * FROM `connect` WHERE `Name` LIKE '\%%e\%'",tmp);
mysql_tquery(connects, mysqlquery, "GetPlayerMySQLID", "i", playerid);
либо
pawn Код:
"SELECT * FROM `connect` WHERE `Name` LIKE '\%\%e\%'",tmp);
Reply
#5

Читать внимательно документацию Format
Quote:

%% Literal '%'

pawn Код:
mysql_format(connects,mysqlquery, sizeof(mysqlquery), "SELECT * FROM `connect` WHERE `Name` LIKE '%%%e%%'",tmp);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)