One of columns(id) in Salesforce custom object is String type though it always contains long type values. I want to run query something like this.
Where id >= '123' and id <= '123456';
Is there any solution for this? It's not possible to change data type of column in Salesforce.
data type conversion is not possible as part of the SOQL syntax. You would need bring back the full result set and filter the results. Or if you can't change the data type then maybe you can use formula field or workflow update to copy the field into a hidden field that you can perform a greater than less than query on. It isn't best practice but it's an idea if you are really stuck for a solution.
Ultimately, though the correct answer would to either pad the number with leading zeros if they need to be text based or change the data type to a number.