mysql substring()函数,字符串分割

时间:2024-01-18 23:02:20
mysql> select * from test;
+----+------------+-------+-----------+
| id | name | score | subject |
+----+------------+-------+-----------+
| | xiaoming | | shuxue |
| | xiaohong | | shuxue |
| | xiaohong | | english |
| | xiaohong | | physics |
| | xiaohong | | astronaut |
| | xiaoming | | physics |
| | xiaoming | | astronaut |
| | xiaoming | | english |
| | xiaobai | | astronaut |
| | .2xiaobai | | english |
| | .2xiaobai | | physics |
| | 3xiaobai | | shuxue |
| | 123xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | .12xiaohei | | english |
+----+------------+-------+-----------+
rows in set (0.00 sec) mysql> select substring(name,,) from test where id=;
+---------------------+
| substring(name,,) |
+---------------------+
| ohong |
+---------------------+
row in set (0.00 sec) mysql> select substring(name,,) from test where id=;
+---------------------+
| substring(name,,) |
+---------------------+
| o |
+---------------------+
row in set (0.00 sec) mysql> select substring(name,,) from test where id=;
+---------------------+
| substring(name,,) |
+---------------------+
| oh |
+---------------------+
row in set (0.00 sec) mysql> select substring(name,,) from test where id=;
+---------------------+
| substring(name,,) |
+---------------------+
| xi |
+---------------------+
row in set (0.00 sec) mysql> select substring(name,,) from test where id=;
+---------------------+
| substring(name,,) |
+---------------------+
| |
+---------------------+
row in set (0.00 sec)