SQL Replace

Discussion in 'MySQL' started by GreatestSwordsman, Dec 23, 2010.

  1. #1
    GreatestSwordsman, Dec 23, 2010 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    You'll need to make a script in PHP or any other language which will parse the content to do the required. This is not possible in MySQL alone.
     
    mwasif, Dec 23, 2010 IP
  3. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #3
    If you are very sure of the format of existing links that last 6 digit number is the file name you would want in new tag, following example would be helpful.

    
    
    
    SET @str = 'http://play.videolog.tv/videos/93/80/398682.flv';
    
    SELECT CONCAT('[videolog]', SUBSTRING_INDEX(SUBSTRING_INDEX(@str, '/', -1), '.', 1), '[/videolog]');
    
    
    Code (markup):
     
    mastermunj, Dec 27, 2010 IP
  4. duben

    duben Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #4
    I guess you have some content before and after this string you need replace. I have Query with solution for this, for 50$, I can send you this solution. If you want it send me PM.
     
    duben, Dec 28, 2010 IP
  5. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #5
    @mastermunj
    Good soultion.
     
    mwasif, Dec 28, 2010 IP
  6. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #6
    @mwasif, Thanks.

    @duben, Why would you want to offer such costly solution when others are helping in free? Respect community rules and avoid selling services anytime anywhere.
     
    mastermunj, Dec 28, 2010 IP
  7. duben

    duben Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #7
    @mastermunj: Because similar solution takes me about 1 hour of work. I didn't see problem to offer complex query for some price. It's similar like offer script. Your solution will work only for setup variable. GreatestSwordsman needs change it in whole database for many records. Usually in WP content there are some random strings before replaced text and some text after. Your solution not count with it.

    My solution will not drop rest of article, properly replace content and leave the rest unchanged. Just it is not free (I know price for my time).
     
    duben, Dec 28, 2010 IP
  8. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #8
    @mastermunj,
    BTW, your solution will only work if this url is the only data in the column. If the URL is in between some other text, then it will not be possible to perform the replace operation.
     
    mwasif, Dec 28, 2010 IP
  9. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #9
    Yes, I am aware about it. I just shared it in case if someone can come up with even better solution using this one.
     
    mastermunj, Dec 28, 2010 IP