anony mous
anony mous

Reputation: 41

How to select specific number in a string based on the stated position in MySQL?

I have this string '275,278,222'

How to SELECT only 278, which is in the second position? or SELECT only 222 which is in the third position?

Upvotes: 0

Views: 15

Answers (1)

anony mous
anony mous

Reputation: 41

second position : SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(STAFFID_, ',', 2),',',-1)

third position : SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(STAFFID_, ',', 3),',',-1)

Upvotes: 1

Related Questions