How to concatenate more than 2 fields with SQL?

SELECT CONCAT(guests.lastname,', ',guests.firstname', ',guests.passport) AS display 
FROM guests 
WHERE guests.uuid = '1'

Kindly try the below one,

SELECT guests.lastname||','||guests.firstname||','|| guests.passport AS display 
  FROM guests 
 WHERE guests.uuid = '1'

You must put commas between all the arguments.

Change:

 SELECT CONCAT(guests.lastname,', ',guests.firstname', ',guests.passport)

to:

 SELECT CONCAT(guests.lastname,', ',guests.firstname,', ',guests.passport) 
                                                    ^

SELECT CONCAT(guests.lastname,concat(', ',concat(guests.firstname,concat(', ',guests.passport)))); 

Tags:

Mysql

Sql