convert() or cast() in valentina

Giacomo Vernoni giacomo at way-out.it
Mon Jan 16 12:04:32 CST 2012


Hi,
I know there's been a discussion back in 2008 about the SQL convert() function, but I need it for something different.

I have a "img_name" field with image names, for example:

IMG_0010.jpg
myPicture10a.jpg
PIC_210_OK.jpg

I need to search for the images that ONLY have the number 10.
In my example, I should get the first two records (that have a "value" of 10), excluding the last one that has a value of 210.

In MySQL I can easily do that with this query:

SELECT * FROM images WHERE CONVERT(img_name, SIGNED) = 10;

or using CAST:

SELECT * FROM images WHERE CAST(img_name as SIGNED) = 10;


How can I do this in Valentina?


CAST() does exist in valentina, but it doesn't work as I expect:
SELECT * FROM images WHERE CAST(img_name AS USHORT) = 20
--› immediately crashes vstudio (VStudio 4.8, Mac OS X 10.6.8).

SELECT CAST(img_name AS USHORT) FROM images
--› returns a strange result (all records, without any field. Nothing.)



Thanks,

Giacomo


More information about the Valentina mailing list