开发者

MySQL alias shorthand?

开发者 https://www.devze.com 2022-12-23 17:53 出处:网络
I need to select all columns from two tables, but need to be able to differentiate between them in the result.

I need to select all columns from two tables, but need to be able to differentiate between them in the result.

Is there a shorthand method of giving each column in the result an alias?

For example:

SELECT t1.*开发者_如何学C AS t1.SOMETHING
     , t2.* AS SOMETHING_ELSE 
  FROM TABLE1 
 INNER JOIN TABLE2 
    ON SOMETHING = SOMETHING_ELSE

In the results, all columns from table one would be prefixes t1, while all results from table two would be prefixes t2.

Any advice appreciated.

Thanks.


No, you'll need to name them explicitly.


No, ALIAS is only for single columns. The only shorthand is to remove the AS:

SELECT column_123 col FROM x

Returns col as the alias.

0

精彩评论

暂无评论...
验证码 换一张
取 消