convert() or cast() in valentina
Giacomo Vernoni
giacomo at way-out.it
Mon Feb 6 10:38:46 CST 2012
Hi Ruslan,
RegEx gave me problems so I tried your solution.
It's useless because:
------------------------------------------
| ImgName | ImgNumber (method) |
------------------------------------------
| "10.jpg" | 10 |
| "IMG_0010.jpg" | 0 |
| "IMG_0210.jpg" | 0 |
------------------------------------------
Your solution only works if the number is at the _beginning_ of the string.
Is this a bug or a normal behaviour?
I need to find images where the numeric part is EXACTLY 10 (in the example above). I don't want "IMG_0210.jpg" to appear if user searches for "10" (that would be an easy "LIKE '%10%').
Any other suggestion?
Giacomo
On 19 gen 2012, at 8:36, Ruslan Zasukhin wrote:
> On 1/18/12 11:43 AM, "Giacomo Vernoni" <giacomo at way-out.it> wrote:
>
> Hi Giacomo,
>
> Yet may be more simple and effective way to use
> Table Methods.
>
> * So you have f1 as string or VarChar
>
> * You make m1 of type Long with method text just f1
> now SELECT m1 will return you Integer value
>
> And
>
> SELECT m1
> FROM T
> WHERE m1 = 10
>
> Will find you EXACT 10
>
>
> Also method you can make indexed -- will be faster searches,
> But more disk and slower a little updates.
>
>
>> Update:
>> On Windows, the RegEx pattern doesn't work, but changing the "$" with "\Z"
>> fixes it.
>> On Mac it works as expected in both ways.
>>
>> So the query should be:
>>
>> SELECT * FROM images WHERE img_name REGEX '^[^1-9]*10[^0-9]\Z*'
>>
>>
>>
>> Giacomo
>>
>>
>> On 17 gen 2012, at 11:29, Giacomo Vernoni wrote:
>>
>>> Just for the records, the solution to my problem is:
>>>
>>> SELECT * FROM images WHERE img_name REGEX '^[^1-9]*10[^0-9]$*'
>>>
>>> where "10" is the number to look for in the img_name field.
>>>
>>> This query only finds names that contain the number 10 in the text (so
>>> "PIC_210_OK.jpg" will NOT be included in the results).
>>>
>>>
>>> For google: valentina convert string to number, valentina search exact number
>>> in string.
>
> --
> Best regards,
>
> Ruslan Zasukhin
> VP Engineering and New Technology
> Paradigma Software, Inc
>
> Valentina - Joining Worlds of Information
> http://www.paradigmasoft.com
>
> [I feel the need: the need for speed]
>
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
More information about the Valentina
mailing list