parameterized query with wildcard

Bob Sneidar bobsneidar at iotecdigital.com
Wed Jul 29 23:35:12 CEST 2015


How odd. I am thinking now, that because I am passing these query arguements to sqlYoga it is doing the macro replacement instead of SQL. Now that I think of it, I have never used this  in a direct SQL query. I am not even sure how to construct it. Is this a web server convention? I cannot see how you would inject the values in a direct query. 

Bob S


> On Jul 29, 2015, at 09:16 , Peter Haworth <pete at lcsql.com> wrote:
> 
> If you are specifying a literal value with LIKE, then you need the single
> quotes or you will get an error.  If you are using a parameter variable
> containing the literal, then no single quotes needed.  Including the :1 in
> quotes makes the query look for a string containing :1, not the contents of
> the variable referred to by :1.
> 
> On Wed, Jul 29, 2015 at 6:33 AM Mike Kerner <MikeKerner at roadrunner.com>
> wrote:
> 
>> Nope.  That doesn't work, Bob.  That returns nothing.
>> 
>> On Tue, Jul 28, 2015 at 7:23 PM, Bob Sneidar <bobsneidar at iotecdigital.com>
>> wrote:
>> 
>>> Should be LIKE ‘:1’ or for wild cards LIKE ‘%:1%’.
>>> 
>>> If you are searching for a value at the beginning, LIKE ‘:1%’ or at the
>>> end, LIKE ‘%:1’
>>> 
>>> If searching for all, column LIKE ‘%:1%’ OR column LIKE ‘:1%’ OR column
>>> LIKE ‘%:1’
>>> 
>>> HTH
>>> 
>>> Bob S
>>> 
>>> 
>>>> On Jul 28, 2015, at 08:16 , Mike Kerner <MikeKerner at roadrunner.com>
>>> wrote:
>>>> 
>>>> Has anybody built any queries that use both parameters and wildcards,
>>> e.g.
>>>> in a LIKE statement?
>>>> 
>>>> SELECT * FROM foo WHERE bar LIKE %:1%
>>>> 
>>>> I've tried the above (error), I've tried '%':1'%' (error), and I've
>> tried
>>>> appending the % to the container I'm passing as my :1 (doesn't work).
>>>> 
>>>> I really don't want to do this the unsafe way.
>>>> --
>>>> On the first day, God created the heavens and the Earth
>>>> On the second day, God created the oceans.
>>>> On the third day, God put the animals on hold for a few hours,
>>>>  and did a little diving.
>>>> And God said, "This is good."
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>> 
>> 
>> 
>> --
>> On the first day, God created the heavens and the Earth
>> On the second day, God created the oceans.
>> On the third day, God put the animals on hold for a few hours,
>>   and did a little diving.
>> And God said, "This is good."
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list