如何用SQL连接两个以上的字段? [英] How to concatenate more than 2 fields with SQL?

查看:1002
本文介绍了如何用SQL连接两个以上的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将CONCAT与SQL结合使用来连接3个字段,并得到以下错误:

I am trying to use CONCAT with SQL to concatenate 3 fields, and get the following error:

对本地函数"CONCAT"的调用中的参数不正确

Incorrect parameters in the call to native function 'CONCAT'

查询如下

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

如何在SQL中连接两个以上的字段?

How do you concatenate more than 2 fields in SQL?

推荐答案

您必须在所有参数之间添加逗号.

You must put commas between all the arguments.

更改:

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

收件人:

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

这篇关于如何用SQL连接两个以上的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆