0

I have a Column Family like this:

  • image_index
    • type as text and primary key
    • value as text
    • id_image as text

I do a SELECT * FROM image_index WHERE type = "image_by_size" ORDER BY value DESC;

Is it possible to compare text like is a int?

Jacky Lormoz
  • 165
  • 2
  • 11

1 Answers1

1

@Jacky Lormoz

Be very careful when comparing numbers (not specifically int, it applies also to long or double) as string.

Example

1L < 2L < 10L

but

"1" < "10" < "2"

if you want to compare numbers as string, add left-padding with 0.

"01" < "02" < "10"

Now, depending on the length of your number, you may need to add many 0 on the left:

"000001" < "000002" < "000010"

doanduyhai
  • 8,712
  • 27
  • 26