I have a database that has a column with a sequence of numbers, and I'm trying to select a range, but the results I am getting are odd.
The column data type is set to VARCHAR, rather than INT since in the future these might contain alphanumeric values, but for now, they are purely numeric.
I tried a statement like "SELECT * FROM table WHERE number >= '1' AND number <= '458'"
, but I am not getting numbers from 1 to 458, I'm getting a sequence like 1, 2, 3, 4, 10, 11, 12... etc.
There are numbers missing, so I assume SQL is applying a logic that I am not familiar with. This query does give me the expected results if I do the search with integers, without the single quotes.
Can someone help me understand the logic SQL uses with strings, I was under the impression that SQL converted the values to integers if applicable?