If there are 2 tables with 3 common columns (say a,b,c) and you are joinig by a, how will you avoid combining the other common columns? Are aliases mandatory? What happens if you don’t give alias?
Asked in the technical stage. Write a PostgreSQL query that joins table_one to table_two using only a, while returning both tables' b and c values without ambiguity.
table_one row and table_two row, plus unmatched table_one rows.record_id, a, separately named b and c values from each table, and status.record_id, then table_two.id ascending.| Column | Type | Description |
|---|---|---|
| record_idPK | INT | Identifier for the first table row |
| a | INT | Column used for joining |
| b | VARCHAR(50) | Text value shared by name with table_two |
| c | DATE | Date value shared by name with table_two |
| amount | NUMERIC(12,2) | Additional value from table_one |
| Column | Type | Description |
|---|---|---|
| idPK | INT | Identifier for the second table row |
| a | INT | Column used for joining |
| b | VARCHAR(50) | Text value shared by name with table_one |
| c | DATE | Date value shared by name with table_one |
| status | VARCHAR(20) | Status associated with the second table row |