yup, this is an ad!
Napalm Riot Forums > Coding (non-game) > Need help updating a field in mySQL

Need help updating a field in mySQL

    Avatar
    Rank
    Private First Class
    Creed
    Strategy
    Joined
    10.18.07

ɤInfog

Rushes With Zerg

I'm looking for a way to make this SQL work on a mySQL server:
Code:
UPDATE tags SET images = (images & ",99") WHERE images <> "*,99*"

In english:
UPDATE the table tags, SET the string in the field images to equal itself plus some text, WHERE the string in the field images does not contain that text already.

I'm used to using SQL in Visual Basic, where I have the luxury of creating and changing variables. I don't really know how to make it work purely in SQL.

The code is for my older brother, who is working on a simple social networking site. He's great at coding, not so great with databases.
08.26.08 6:52 pm
    • Avatar
      Rank
      Private First Class
      Creed
      Strategy
      Joined
      10.18.07

    ɤInfog (#24589)

    Rushes With Zerg

    Never mind, I found the wildcards for SQL. It works now.
    08.27.08 4:00 pm
      • Avatar
        Rank
        Private First Class
        Creed
        Action
        Joined
        10.18.07

      ɤSkyrail (#24803)

      Team Kills For A Living

      Good to hear you fixed it, I had problems when using * as a wildcard, only to realise SQL uses % instead :)
      ---
      Make love, and war.
      09.14.08 9:06 pm
    • Avatar
      Rank
      Sergeant
      Creed
      Action
      Joined
      03.17.08

    ʊaapis (#24952)

    Isn't my real name.

    Methinks if you have to explain it in 'plain English', your audience isn't going to know what's wrong anyways. :P A SQL developer would already know what you're talking about.
    ---
    Ryan Priebe
    UI & Graphic Designer
    Napalm Riot Inc.
    09.19.08 5:21 pm
      • Avatar
        Rank
        Specialist
        Creed
        Action
        Uber Subscriber Joined
        02.25.08

      ӝCoolhand2 (#24958)

      Kills People While They Type

      Methinks he probably has already guessed that there's at least one or two people who know SQL on the site, and as such probably didn't need to try "plain English".
      ---
      Remember, the answer is always 42.
      09.19.08 11:24 pm
        • Avatar
          Rank
          Sergeant
          Creed
          Action
          Joined
          03.17.08

        ʊaapis (#24965)

        Isn't my real name.

        And yet he did.. ? Oh well.
        ---
        Ryan Priebe
        UI & Graphic Designer
        Napalm Riot Inc.
        09.20.08 4:02 am