I am trying to select a field from MySQL table and remove a substring from that field, and update that field.
For example: VAR1010 I want to replace and update VAR with SHS and the remaining part is the same. The result I am expecting is SHS1010
Here is the code:
SELECT SUBSTR(R.regnumber,4,4) as RegNo from registration R WHERE R.teacheremail='param';
UPDATE registration SET regnumber = 'SHSRegNo' where teacheremail='param';
But it’s updating as RegNo.
You can do this in one
UPDATEstatement:See SQL Fiddle with Demo