I wrote my SQL code like this and the latest ID it return is S9 Just keep in mind that I want the alphabet beside the number. So which SQL code allow me to select the latest ID that is S12 ? PLS help me.
SELECT IdSoalan FROM SOALAN ORDER BY IdSoalan DESC LIMIT 1
Try this:
SELECT IdSoalan FROM SOALAN ORDER BY LENGTH(IdSoalan) DESC, IdSoalan DESC LIMIT 1
It sorts by length of the column in a descending order and then by the value in a descending order and limits the result to 1. It's called natural sorting in MySQL.