知道字符串前3位的最佳方法是什么? 我已经为此写了一个函数。它按预期工作,但我想知道是否有更好的方法来做到这一点。
mysql> select areacode_fun('233434535');
+---------------------------+
| areacode_fun('233434535') |
+---------------------------+
| 233 |
+---------------------------+
1 row in set (0.00 sec)
mysql> select areacode_fun('2 33434535');
+----------------------------+
| areacode_fun('2 33434535') |
+----------------------------+
| 233 |
+----------------------------+
1 row in set (0.00 sec)
mysql> select areacode_fun('2a33434535');
+----------------------------+
| areacode_fun('2a33434535') |
+----------------------------+
| 233 |
+----------------------------+
1 row in set (0.00 sec)
mysql> select areacode_fun('(2a3)3434535');
+------------------------------+
| areacode_fun('(2a3)3434535') |
+------------------------------+
| 233 |
+------------------------------+
1 row in set (0.00 sec)