splitting apart a mysql column with mutliple values. Not sure how to display

Discussion in 'Databases' started by xbat, Nov 27, 2017.

  1. daoustma

    daoustma Member

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #21
    If you want something "dirty" that may do the job (temporarily), try something like this. It isn't pretty and only works for a set number of substrings values.

    
    SELECT
      tp.id,
      tp.selected_y,
      tp.selected_m,
      SUBSTRING_INDEX(tp.all, 'add to bob', 2) AS value
      FROM tp
    UNION
    SELECT
      tp.id,
      tp.selected_y,
      tp.selected_m,
      SUBSTRING_INDEX(SUBSTRING_INDEX(tp.all, 'add to bob', 3), 'add to bob', -1) AS value
      FROM tp
    UNION
    SELECT
      tp.id,
      tp.selected_y,
      tp.selected_m,
      SUBSTRING_INDEX(SUBSTRING_INDEX(tp.all, 'add to bob', 4), 'add to bob', -1) AS value
      FROM tp
    
    Code (markup):
     
    Last edited: Dec 16, 2017
    daoustma, Dec 16, 2017 IP
  2. xbat

    xbat Well-Known Member

    Messages:
    326
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    105
    #22
    thank you.
     
    xbat, Dec 16, 2017 IP