简体   繁体   English

在mySQL中选择所有(*)字段时别名为单个字段

[英]Alias a single field while selecting all(*) fields in mySQL

What I want to do: 我想做的事:

I would like to retrieve all data fields from a Table and ALIAS only a single field, called organizationId as id . 我只想从Table和ALIAS中检索所有数据字段,只有一个字段称为organizationIdid


Here is my Query: 这是我的查询:

SELECT * FROM watson_schema.organization

The question: 问题:

Is this something possible to do when using the all selector( * ) or do I need to ditch selecting-all and select all fields individually, aliasing the ones I want. 使用all选择器( * )时是否可以这样做,还是我需要放弃全选并单独选择所有字段,使我想要的字段成为别名呢。

Well, you basically have two options. 好吧,您基本上有两个选择。

1) Selecting this column twice something like : 1)选择两次此列,如:

SELECT t.*,t.organizationID as ID FROM watson_schema.organization t

2) You have to ditch selecting all and specify the columns.. 2)您必须放弃选择所有内容并指定列。

SELECT col1,col2,organizationID as ID,col4,col5 FROM watson_schema.organization

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM