I've a MySQL table with the following data.
When I pass the login_id, value should display like rows and it should be select query only and should not any other methods.
Example: when I pass login_id as "22", it should display like below:
I've a MySQL table with the following data.
When I pass the login_id, value should display like rows and it should be select query only and should not any other methods.
Example: when I pass login_id as "22", it should display like below:
Try this
SELECT SUBSTRING_INDEX(`applicable_branches`, ', ', 1) AS`speditor1`, SUBSTRING_INDEX(`applicable_branches`, ', ', -1) AS `speditor2` FROM `myTable` where `id`= 22
You can read more about it at https://coderwall.com/p/zzgo-w/splitting-strings-with-mysql
MySQL doesn't provide any built-in function for doing this. Although you can manage doing it by several ways from which one of the way is.
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(applicable_branches, ',', number), ',', -1) output FROM table_name, (SELECT 1 number UNION ALL
SELECT 2 UNION ALL
SELECT 3) numbers;
Where number can be the maximum occurrences of comma that you think can occur in the column value.
Here the max number will be 3.
Add SELECT n UNION ALL
if needed for occurrences.