Not sure how to do this... if someone can help me.
I have a query that looks for a record which has "firstname" and "lastname" fields. I want it to take those two fields and combine them under a new variable name called "fullname". How would this look?
Combining Fields in Query
Moderator: General Moderators
A SELECT expression may be given an alias using AS.
Code: Select all
SELECT firstname, lastname AS fullname FROM table ORDER BY fullname;Well here it is...
Kriek-
I tried that but it did not work. I think it reads the "firstname" as a field and then "lastname" as a field with a new variable name, which is "fullname".
Nevertheless, I was able to pull it off with the CONCAT.
It displayed the firstname (John) and the lastname (Doe) as the fullname (John Doe).
Superb!
I tried that but it did not work. I think it reads the "firstname" as a field and then "lastname" as a field with a new variable name, which is "fullname".
Nevertheless, I was able to pull it off with the CONCAT.
Code: Select all
SELECT CONCAT("firstname", " ", "lastname") AS fullname FROM tableSuperb!
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC