Remove what's after a comma

Discussion in 'MySQL' started by Fracisc, Apr 14, 2015.

  1. #1
    Fracisc, Apr 14, 2015 IP
  2. Nigel Lew

    Nigel Lew Notable Member

    Messages:
    4,642
    Likes Received:
    406
    Best Answers:
    21
    Trophy Points:
    295
    #2
    Nigel Lew, Apr 15, 2015 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    A regular expression would work in addition to the above method.
     
    jestep, Apr 16, 2015 IP
  4. ezfile

    ezfile Greenhorn Affiliate Manager

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #4
    If you are using php

    $string = 'http://www.test.com/imga1.php, http://www.test.com/imga2.php';
    $string_arr = explode(','. $string );
    $first = $string_arr[0];

    Not sure why you want to do this in mysql or storing data like that in mysql...
     
    ezfile, Apr 20, 2015 IP
  5. Amelie001

    Amelie001 Greenhorn

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #5
    you can use SUBSTRING_INDEX(str,delim,count) function with update query
     
    Amelie001, May 26, 2016 IP