How to get Max id in table column database?when id store as string?

433 Views Asked by At

In my app i want to get max id from my column .am using Max function get max id 0-9 ,,but after 10 its not work.

The reason is am store id datatype as TEXT not an INT.How to get max id from that id column for all vales?

1

There are 1 best solutions below

0
On BEST ANSWER

Try like this

SELECT max(CAST(id as int)) from TABLE_NAME

Using Sqlite CAST you can do it. But it will be good if you choose integer for id column.