I have a string for example 'p2p3p4p9c5c6c7' I make a selection-statement in mysql I want to tell how many strings are in the initial string in the ('p6', 'p7', 'p8' or 'p9') . The result of my example should be 1, because only 'p9' is in my string. I can not find a good way of doing this, can someone help?
The second example 'k2p4p6p8p9c8' should be the result here
However, the best answer I can think of is a situation that has been added together:
(str like '% P6%') NumInString MySQL Boolean as a numeric + (str '% p7%') + (str '% p8%') + ('str'% p9% '' as str) Believes in the form of integers in the context, is correct for "1" and is wrong for "0".
I should repeat that if the substrings are actually some types of codes, they should be stored in a separate junction table in one row per code and on the original line.
No comments:
Post a Comment