2017-07-26 69 views

回答

0

這是因爲bm = 5x112.30它沒有/字符

+0

但我應該如何驗證bp2?有些情況下,bm的值將會是5x112.30/5x120.56。 –

+0

你想'bp1' ='5x112.30'和'bp2' ='5x120.45'? –

1

我固定它通過創建函數split(字符串,分隔符,否)。這是我的代碼:

DELIMITER $$ 

CREATE FUNCTION split(str VARCHAR(500), delchar VARCHAR(2), x INT) 
RETURNS VARCHAR(500) 
BEGIN 
RETURN SUBSTR(SUBSTRING_INDEX(str, delchar, x), 
LENGTH(SUBSTRING_INDEX(str, delchar, x-1))+IF(x > 1, 2, 1)); 
END$$ 

DELIMITER ; 

bp1 = split('5x112.30/5x120.45','/',1);

bp2 = split('5x112.30/5x120.45','/',2);