www.webdeveloper.com
Results 1 to 3 of 3

Thread: concatenation in SQL query

  1. #1
    Join Date
    Jul 2005
    Posts
    49

    concatenation in SQL query

    this is not working!

    update user set username="`fname` `lname`" where 1

    i want that username should be set as fname.' '.lname
    without looping, with single query!

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    this typically works:
    Code:
    UPDATE user SET username=fname||" "||lname;
    the ||" "|| adds a space between them, typically not a good idea for usernames to ahve spaces though, might want to change it to an underscore or something

    Note that in MySQL you'll need to use the concat function so it'd be
    Code:
    UPDATE user SET username=concat(fname," ",lname);
    hope that helps.
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  3. #3
    Join Date
    Jul 2005
    Posts
    49

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles