简体   繁体   中英

How to combined first_name and last_name using sql query?

There are two columns in database as name FIRST_NAME and LAST_NAME.i want to join both the name and display in single column. The query which is used by me is given below but it gives error as Incorrect syntax near 'NAME'.

Modify the query:

SELECT [CREATED_ON], MUD.PK_ID AS USER_ID, 
(MUD.FIRST_NAME + ' ' + MUD.LAST_NAME NAME) 
AS NAME FROM USER_TABLE

Remove the erroneous 'NAME'. eg

SELECT [CREATED_ON], MUD.PK_ID AS USER_ID, (MUD.FIRST_NAME + ' ' + MUD.LAST_NAME) 
AS NAME FROM USER_TABLE
SELECT 
   [CREATED_ON], 
   MUD.PK_ID AS USER_ID, 
   (MUD.FIRST_NAME + ' ' + MUD.LAST_NAME) AS [NAME]
FROM
   USER_TABLE

The parentheses around the expression MUD.FIRST_NAME + ' ' + MUD.LAST_NAME are optional.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM