Skip to content
Advertisement

postgresql how to choose specific column from exact same columns?

I have table A and B. If I inner join them like

The new table has two exactly the same columns “a”. How do I choose the first column of “a”? Or how do I avoid generate two same columns after inner join?

Advertisement

Answer

You can use an alias for each column such as:

That way, for matching ID=1, if firstname is ‘John’ in table a but ‘Jon’ in table b, you can print them appropriately.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement