MySql-将ALIAS用于多列 [英] MySql - use of ALIAS for multiple columns
问题描述
我看到了以下代码:
SELECT
u.ID,u.username,u.active, u.email,u.admin,u.banned,
u.name AS组成员身份
来自用户u
WHERE u.ID = {$ uid}
,并且想知道有关别名多列的官方文档在哪里。 W3schools(不是最佳来源)是我通过以下方式找到文档的唯一地方:
SELECT column_name(s )FROM table_name AS alias_name;
http://www.w3schools.com/sql/sql_alias.asp
我希望收到指向官方文档的链接,所以我可以查看一下。
您不能对多个列使用相同的别名,但可以将值连接起来并给结果别名:
SELECT
u.ID,u.username,u.active,u.email,u .admin,u.banned,
u.name + u.username作为组成员
FROM用户u
如果这是您想要的,请在此处中查看如何处理空值。 p>
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.
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.
这篇关于MySql-将ALIAS用于多列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!