SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Nov 2001
    Location
    Fort Lauderdale
    Posts
    814
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy To the gurus, is it possible to create a statement that matches only part of a value?

    Greetings,

    I'm not even sure if this is possible, but here is the scenario:

    1. I have a table called dir_websites
    2. In that table, I have a field/column called "url"

    Now this table is filled with entries that have a similar URL containing "folderA" in it. For example:

    - http://www.mywebsite.com/folderA/subfolderA
    - http://www.mywebsite.com/folderA/subfolderB
    - http://www.mywebsite.com/folderA/subfolderC
    - http://www.mywebsite.com/folderA/subfolderD
    - http://www.mywebsite.com/folderA/subfolderE

    I want to change all the entries in the table that has the "folderA" in it's url to not contain the "folderA" part in their url. For example:

    - http://www.mywebsite.com/subfolderA
    - http://www.mywebsite.com/subfolderB
    - http://www.mywebsite.com/subfolderC
    - http://www.mywebsite.com/subfolderD
    - http://www.mywebsite.com/subfolderE

    ------

    Basically the website moved it's development website in the /folderA/ folder, to the live website on root. However all the urls were hardcoded with /folderA/ in the database table.

    There are over 280 entries in the table.

    I don't need the PHP version because I would like to just run the sql statement in phpmyadmin.

    Is something like the above possible or am I out of luck?

    Thank you in advance.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Code MySQL:
    UPDATE dir_websites
    SET url = CONCAT('http://www.mywebsite.com/', SUBSTR(url, 33))
    WHERE url LIKE 'http://www.mywebsite.com/folderA/%'


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •