SA-MP Forums Archive
[Solved] Little problem with SQLite - 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: [Solved] Little problem with SQLite (/showthread.php?tid=375802)



[Solved] Little problem with SQLite - LetsOWN[PL] - 08.09.2012

Heya all.
Just quick question, cuz I somehow can not figure out answer for myself.

pawn Код:
format(_qr,128,"Select Name from nameTable Where Name Like \"%%%s%%\"","Blah");
Код:
SQLite syntax: Select COLUMN From TABLE Where SOMETHING Like %Text%
(Text - any text you want)
What it does?
It should return all records from 'Name' column, if there is 'Blah', for example:
Код:
ID + Name  + Money
1  | OBlah | 50
-----------------
2  | Blah1 | 64
------------------
3  | lol   | -666
------------------
4  | Blah2 | 5
It should return me OBlah, Blah1 and Blah2.
It works with my .db browser, but the question is, how to make %variable% readable for SAMP Server?
I tried to print it this way:
pawn Код:
new Str[12];
format(Str,12,"\"%%%s%%\"", "Blah");
printf(Str);
and
pawn Код:
new Str[12];
format(Str,12,"\"%s%s%s\"","%","Blah","%");
printf(Str);
Yes \" were neccessary..
In both cases I've received only and only this:
Код:
"Blah"
.. but it should print
Код:
"%Blah%"
Anyone knows wheres the mistake?
Thanks a lot.

Greetz,
LetsOWN



SOLVED.

Solution:
pawn Код:
format(String,sizeof(String)," '%s%s%%'","%","Input");
Prints
Код:
'%Input%'
like a charm.


Greetz,
LetsOWN