I have to insert sequential number from 1 to N in an empty column in a database. Android Studio is giving me the following error when I run my code:
Caused by: android.database.sqlite.SQLiteException: unrecognized token: ":" (code 1): , while compiling: SELECT @i:=0; UPDATE table_name SET column_one = @i:=@i+1;
My line of code:
db.execSQL("SELECT @i:=0; UPDATE table_name SET column_one = @i:=@i+1;");
(Please note when I change MySQL statement between parenthesis the code runs and gets executed)
Source of SQL code:
Insert sequential number in MySQL
I'm new in Java, Android Studio and MySQL.
What am I missing here?
Help me to understand why MySQL @i:=@i+1 expression is not running properly in Android Studio.
Thanks in advance.