Reputation: 10380
I saw the following code:
SELECT
u.ID, u.username, u.active, u.email, u.admin, u.banned,
u.name AS groupmemberships
FROM users u
WHERE u.ID={$uid}
and was wondering where the official documentation about aliasing multiple columns was. W3schools (not the best source) as the only place where I found "documentation" in the following way:
SELECT column_name(s) FROM table_name AS alias_name;
http://www.w3schools.com/sql/sql_alias.asp
I would appreciate a link to official documentation so I can look it over.
Upvotes: 1
Views: 7659
Reputation: 832
You can use concat
function to get single alias for multiple columns,
select concat(first_name, ' ', last_name) as employee_name from user;
Upvotes: 1
Reputation: 7019
You can't use the same alias for multiple columns, but you can concatenate values and give the result an alias:
SELECT
u.ID, u.username, u.active, u.email, u.admin, u.banned,
u.name + u.username AS groupmemberships
FROM users u
If this is what you want, then check here for how to deal with null values.
Upvotes: 3