MySQL: is it possible to have wildcards in AS aliases?

I have a bunch of fields called the same for several tables (I inherited it - don't blame me;).

Instead of setting all aliases in detail, is it possible to assign / add an alias automatically using a template?

I imagine something like (which of course does not work):

SELECT t1.*,t2.* as alias2.*, t3.* as alias3.*

So, I would get the returned fields:

name, address, city, state
alias2.name, alias2.address, alias2.city, alias2.state
alias3.name, alias3.address, alias3.city, alias3.state
+3
source share
1 answer

It does if you use it like:

SELECT t1.*, alias2.*, alias3.*
  FROM t1, 
       t2 AS alias2, 
       t3 AS alias3

Define a table alias, then you can use a table alias. * in SELECT. But it still makes the correct address/ etc field a pain without a unique column alias ...

Renouncement

ANSI-89 - .

+2

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


All Articles