SQL statement seeking guidance
Table Name: table1
Field: ID value (number plus comma/number of digits indeterminate)
Content A:1 3,5
Content B:2 3,3
Content C:3 3,4,5
Content D:4 5,3,6
All I have to do is find the corresponding ID. Replace 3 in the Value field with 4 to replace only one
The final effect to achieve
Content A:1 4,5
Content B:2 4,3
Content C:3 4,4,5
Content D:4 5,4,6
SQL statements: SQL PHP MySQL
Share to:
------Solution--------------------
Oracle, MySQL does not test, the corresponding function for MySQL should be able to.
Select Replace (firststr, ' s ', ' a ')
------Solution--------------------
Secondstr
From (SELECT substr (str, 0, InStr (str, ' s ')) Firststr,
substr (str, InStr (str, ' s ') +1) secondstr
From (select T1.value str from table1 t1 where t1.id=1))
------Solution--------------------
Sorry I just forgot to change the character.
Oracle, MySQL does not test, the corresponding function for MySQL should be able to.
Select Replace (FIRSTSTR, ' 4 ', ' 3 ')
------Solution--------------------
Secondstr
From (SELECT substr (str, 0, InStr (str, ' 4 ')) Firststr,
substr (str, InStr (str, ' 4 ') +1) secondstr
From (select T1.value str from table1 t1 where t1.id=1))
------Solution--------------------
Select Replace (FIRSTSTR, ' 3 ', ' 4 ')
------Solution--------------------
Secondstr
From (SELECT substr (str, 0, InStr (str, ' 3 ')) Firststr,
substr (str, InStr (str, ' 3 ') +1) secondstr
From (select T1.value str from table1 t1 where t1.id=1))