SET @t3 = SUBSTRING_INDEX(SUBSTRING_INDEX(id, '-', -2), '-', 1); Są na to inne sposoby, ale ten uważam za dość zabawny :)