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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Simple SQL Update Problem

  • 01-07-2009 9:04am
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 3,721 ✭✭✭E39MSport


    SEL FNAME||LNAME


  • Registered Users, Registered Users 2 Posts: 211 ✭✭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