concat()函数的功能是字符串的拼接
concat(字符串1,字符串2,字符串3,...);
如:
name = "hello,my name is sql"
age = 18
sex = male
a = concat(name,age,sex);
输出:hello,my name is sql 18 male
函数亦可组合使用:
编写 SQL 语句,返回顾客 ID(cust_id)、顾客名称(cust_name)和登录名(user_login),其中登录名全部为大写字母,并由顾客联系人的前两个字符(cust_contact)和其所在城市的前三个字符(cust_city)组成。提示:需要使用函数、拼接和别名。
select cust_id,cust_name,
upper(concat(substring(cust_name,1,2),substring(cust_city,1,3))) as user_login
from Customers