SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Update query with wildcards

    I am new to sql and trying to update a bunch of records , i tried selecting them all, and they came fine when i used the wildcards, but now when i run the following command, it returns, 0 rows affected.
    Code SQL:
    UPDATE wp_comments
    SET comment_author_url= '/wp-content/themes/abc/images/new.png'
    WHERE comment_author_url= '/gender/%'

    am i missing something, or the wildcards doesn't work with update?
    All those who wander aren't lost.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    was that ampersand supposed to be a mysql wildcard? because it isn't
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard nofel's Avatar
    Join Date
    Aug 2007
    Location
    Earth
    Posts
    1,766
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    was that ampersand supposed to be a mysql wildcard? because it isn't
    sorry, my mistake. i later on fixed it and retried it, but didn't work. am i missing something
    All those who wander aren't lost.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    it didn't work if you used an equal sign -- you need to use LIKE
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the update statement:

    Code:
    UPDATE wp_comments
    SET comment_author_url= '/wp-content/themes/abc/images/new.png'
    WHERE comment_author_url LIKE '/gender/%'


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
  •