Divided string in the mysql query

i have field that has records like ‘1:23,2:23’ and ‘2:43’

is there any way to split string into 1,23,2,23 (separate values, so i can work with them independently) using mysql query. for example add them to another table like

row1:   1 | 23
 row2:   2 | 43

the string can contain more pairs of keys/ values

I may misunderstand your question but here are my thoughts…

SQL is meant to fetch data, not parse it. Parsing should happen on the application side. If you need to create a list for something like an IN clause then you probably need to reconsider you data-model to allow the values you would normally parse out to be in separate rows.

I am not saying you can’t do some string magic in SQL but it’s usually a sign of a design issue.

Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 后端存储 » Divided string in the mysql query

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录