返回从字符串str分隔符delim中的计数发生前的子字符串。 如果计数是正的,则返回一切到最终定界符(从左边算起)的左侧。如果count为负,则返回一切到最后一个分隔符(右算起)的右侧。SUBSTRING_INDEX() 搜索delim时进行区分大小写的匹配。
select * , concat(SUBSTRING_INDEX(remarks, 'NRIC: ', 1), "Ref No.: ", SUBSTRING_INDEX(remarks, 'Ref No.: ', -1)) as new_remarks #, SUBSTRING_INDEX(remarks, 'NRIC: ', 1) as before_nric #, SUBSTRING_INDEX(remarks, 'Ref No.: ', -1) as after_ref_no from voucher_action where action_id in (30, 32) and remarks like '%NRIC: %' order by id desc limit 100