I am joining two tables house and tower, both have some of the same column names such as id, created_at, deleted, address etc. I wonder if it is possible to return the columns in the following fashion: house.created_at, house.id, tower.created_at, tower.id etc. I know I can query with AS, I was wondering if it is possible to query something like this: SELECT house.* AS house, tower.* AS tower
. I tried it like this, but it was not valid SQL. Any idea how I can chase the column names prefix easily ?
Asked
Active
Viewed 2,464 times
0

jjuser19jj
- 1,637
- 3
- 20
- 38
-
No, that's not possible. You have to write the alias for each column individually – Oct 19 '18 at 20:33
-
2See here: https://stackoverflow.com/q/5179648/330315 – Oct 19 '18 at 20:35
-
Why isn't using the table alias in the select list sufficient? – Mureinik Oct 19 '18 at 20:36