mySQL gurus...quick question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FlexxAeon
    Confirmed User
    • May 2003
    • 3765

    #1

    mySQL gurus...quick question

    i'm trying to do a query via phpMySQL where i add onto data that already exists in a field. Example: right now the field contains "this is my text" and i want to make it read "this is my text i hope you like it" without replacing it but adding "i hope you like it" onto it. i tried this:

    Code:
    UPDATE tablename SET fieldname = (fieldname + 'i hope you like it') WHERE 'id' = 1;
    and other slight variations...but no go. can't seem to find exactly what i'm looking for in searches either.

    little help please?
    flexx [dot] aeon [at] gmail
  • netpimp
    Registered User
    • Jan 2005
    • 66

    #2
    Originally posted by FlexxAeon
    i'm trying to do a query via phpMySQL where i add onto data that already exists in a field. Example: right now the field contains "this is my text" and i want to make it read "this is my text i hope you like it" without replacing it but adding "i hope you like it" onto it. i tried this:

    Code:
    UPDATE tablename SET fieldname = (fieldname + 'i hope you like it') WHERE 'id' = 1;
    and other slight variations...but no go. can't seem to find exactly what i'm looking for in searches either.

    little help please?

    You could try:

    Code:
    UPDATE tablename SET fieldname = CONCAT(fieldname, 'i hope you like it') where id=1;
    Make sure to put appropriate spacing where ya need it or it'll run together.

    Comment

    • FlexxAeon
      Confirmed User
      • May 2003
      • 3765

      #3
      well that actually produced a result (unlike my code lol) but it popped a "0" in the place where the original text was
      flexx [dot] aeon [at] gmail

      Comment

      • FlexxAeon
        Confirmed User
        • May 2003
        • 3765

        #4
        scratch that u were right i just had to make a few syntax tweaks. thanks!
        flexx [dot] aeon [at] gmail

        Comment

        • brandonstills
          Confirmed User
          • Dec 2007
          • 1964

          #5
          what are you trying to do exactly? usually you do this once you get the information. not sure why you are trying to do it directly in the query.

          Brandon Stills
          Industry and programming veteran
          [email protected] | skype: brandonstills | ICQ #495-171-318

          Comment

          • FlexxAeon
            Confirmed User
            • May 2003
            • 3765

            #6
            trying to build something custom using info from a sponsors generator....but the way i was doing it, i had to get the info in two parts...so i ran an insert query with the first part and then an update query with the second part.... it was a pain in the ass but i got it
            flexx [dot] aeon [at] gmail

            Comment

            Working...