SA-MP Forums Archive
Оператор LIKE в запросе - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Русский/Russian (https://sampforum.blast.hk/forumdisplay.php?fid=32)
+---- Thread: Оператор LIKE в запросе (/showthread.php?tid=552576)



Оператор LIKE в запросе - Daea - 25.12.2014

Добрый день!
Как можно послать запрос в БД с оператором 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



Re: Оператор LIKE в запросе - kennydalglish - 25.12.2014

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


Re: Оператор LIKE в запросе - Daea - 25.12.2014

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


Re: Оператор LIKE в запросе - SoNikMells - 25.12.2014

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);



Re: Оператор LIKE в запросе - Stepashka - 25.12.2014

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

%% Literal '%'

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