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 1,327 times
0
a_horse_with_no_name
- 497,550
- 91
- 775
- 843
jjuser19jj
- 1,463
- 3
- 18
- 37
-
No, that's not possible. You have to write the alias for each column individually – a_horse_with_no_name Oct 19 '18 at 20:33
-
2See here: https://stackoverflow.com/q/5179648/330315 – a_horse_with_no_name 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