I have a column in a table called multi_values.
In that column I am inserting multiple values by using + separator.
For example
01234567891111+01234567891112+01234567891113+01234567891114
This column may contain some times two values , some times 4 values dynamically.
So I would like to get first 3 values from that column.
If that column contains only 2 values then 2 , if it contains only one value then one.
I tried with mysql substring.
But the values are not fixed length in that column.
So I need a select query to get first 3 values from that column.
Any help would be greatly appreciated.
`Answer`
At the time of inserting in that particular column values are inserting starting with + sign. Like +123+2344+34563 like this. So here is the solution.
SUBSTR(
column_name,2)
. So this will remove the first + sign.
Below one giving what I expect
SUBSTRING_INDEX(SUBSTR(
column_name,2),'+',3)
.
So it will return 3 Ids.