Select * and make an alias over one column

Allows itself the union of three tables, for example, 14 columns. I would like to rename one of the columns with an alias. Is there a way or way to do this without writing the other 13 column names in the select statement?

What I'm looking for in pseudo code

SELECT * [rename user.login as username] from users join 
        (select * from statistics join accounts)
+5
source share
2 answers

Your suggested syntax is good, IMO. In fact, it is very similar to the Tutorial D database language :

user RENAME ( login AS username )

will project all 14 attributes from relvar userwith one renamed as indicated.

Similarly, Tutorial D has a design statement ALL BUT, for example.

user { ALL BUT login }

will result in a ratio of 13 attributes in your case.

, SQL , , . , , , SELECT * ; ! , SQL, SELECT * BUT <commalist> SQL, . SELECT * !

+3
select users.login as username, users.* 
     from users

, , .

:

select u.login as username, u.*, s.* 
     from users as u, statistics as s 
     where u.user_id = s.user_id
+4

All Articles