NO. like this : 3B-211-1 or S-101. The number in the middle is the number of office i only want the first number of the number in the middle , how?  for example 3B-211-1 i want the 2 only ; and S-101, i want the 1 only...thank you very much..

解决方案 »

  1.   

    SELECT mid(SUBSTRING_INDEX(SUBSTRING_INDEX('3B-211-1 ', '-', 2), '-', -1),1,1);
      

  2.   


    mysql> select substring('3B-211-1',LOCATE('-','3B-211-1')+1,1);
    +--------------------------------------------------+
    | substring('3B-211-1',LOCATE('-','3B-211-1')+1,1) |
    +--------------------------------------------------+
    | 2                                                |
    +--------------------------------------------------+
    1 row in set (0.11 sec)