Home > Net >  How to get all columns in PostgreSQL along with CONCATing two columns?
How to get all columns in PostgreSQL along with CONCATing two columns?

Time:03-17

So i am joining these two tables A and B B contains first_name and last_name So i am writing query like this

select col1,col2,...,col12,CONCAT(first_name,last_name) as NAME 
from A 
  INNER JOIN B on A.email=B.email;

Now i want all columns from this query but instead of writing all column names...are there any ways to get every column along with concatenation of these two first_name and last_name?

CodePudding user response:

Use *

select *, CONCAT(first_name,last_name) as NAME 
from A 
  INNER JOIN B on A.email=B.email;

If you want to get the join column only once, you can use:

select *, CONCAT(first_name,last_name) as NAME 
from A 
  INNER JOIN B using (email);
  • Related