Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Simple SQL Update Problem

Options
  • 01-07-2009 10:04am
    #1
    Registered Users Posts: 500 ✭✭✭


    I have 3 columns:
    firstname (populated)
    surname (populated)
    fullname (empty)

    Update Mytable set fullname = firstname + " " + surname;

    It does not work - it puts 0.0 in all columns - however its a varchar column.

    Is it something obvious?


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    What DBMS are you using?

    If it's MySQL, you need to use CONCAT()

    Using an arithmetic operator makes MySQL think that you're adding numbers together and it will interpret all strings as 0.


  • Registered Users Posts: 3,721 ✭✭✭E39MSport


    SEL FNAME||LNAME


  • Registered Users Posts: 210 ✭✭MsQuinn


    Update Mytable set fullname = trim(nz(firstname,"")) & " " & nz(trim(surname,""));

    SQL doesn't know what to do with nulls so convert them when you are trying to concatenate (can't spell).


Advertisement