简体   繁体   English

如何使用sql查询组合first_name和last_name?

[英]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. 数据库中有两列,分别是名称FIRST_NAME和LAST_NAME。我想同时加入该名称并在单列中显示。 The query which is used by me is given below but it gives error as Incorrect syntax near 'NAME'. 下面提供了我使用的查询,但由于“ 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'. 删除错误的“ 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. 表达式MUD.FIRST_NAME + ' ' + MUD.LAST_NAME是可选的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过First_Name和/或Last_Name查询sql表 - query sql table By First_Name and/or Last_Name 查询以使用外键获取行值(first_name 和 last_name) - Query to fetch row values (first_name & last_name) using foreign key 具有名称,名字和姓氏的PostgreSQL多表查询 - PostgreSQL multi-table query with name, first_name, and last_name 如有空格,如何将NAME分为3个不同的字段FIRST_NAME,MIDDLE_NAME和LAST_NAME - How to split NAME into 3 different fields FIRST_NAME, MIDDLE_NAME & LAST_NAME when there is a space 如何编写查询以获取订单包含超过 2 件商品的客户的名字和姓氏? - How do I write a query to get the first_name and last_name of customers having orders containing more than 2 items? GROUP BY First_Name,但显示COUNT个对应的Last_Name SQL - GROUP BY First_Name but show COUNT of the corresponding Last_Name SQL 使用 Reg_exp 从电子邮件预言机中提取名字和姓氏 - Extracting First_name & Last_name from email oracle using Reg_exp PHP-如何在登录后获取正确的名字和姓氏? - PHP - How to get correct first_name and last_name after login? 试图在 Oracle SQL 中将 FULL_NAME 分成 FIRST_NAME 和 LAST_NAME,但它没有显示表本身的任何更改 - Trying to separate a FULL_NAME into FIRST_NAME and LAST_NAME in Oracle SQL, but it does not show any changes on the table itself 选择 concat(first_name,' ',last_name) 作为员工的“全名”---在 oracle 中连接 2 列时如何带空间--- - select concat(first_name,' ',last_name) as "full name "from employees ---how to bring space when 2 columns are concatenated in oracle---
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM