MySQL alias abbreviation?

I need to select all the columns from two tables, but I need to be able to distinguish between them as a result.

Is there an abbreviated method of providing each column as a result of an alias?

For instance:

SELECT t1.* AS t1.SOMETHING , t2.* AS SOMETHING_ELSE FROM TABLE1 INNER JOIN TABLE2 ON SOMETHING = SOMETHING_ELSE 

In the results, all the columns from the first table will be t1 prefixes, while all the results from table 2 will be t2 prefixes.

Any advice is appreciated.

Thanks.

+4
source share
2 answers

No, you will need to specify them explicitly.

+3
source

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

 SELECT column_123 col FROM x 

Returns col as an alias.

+3
source

Source: https://habr.com/ru/post/1304578/


All Articles