Click to See Complete Forum and Search --> : concatenation in SQL query


emin3m
01-09-2006, 07:59 PM
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!

chazzy
01-09-2006, 09:22 PM
this typically works:

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

UPDATE user SET username=concat(fname," ",lname);

hope that helps.

emin3m
01-26-2006, 10:49 AM
uhh nice
thanx man