CONCAT_WS SQL Server查询创建用户名 [英] CONCAT_WS SQL Server Query creating a username

查看:92
本文介绍了CONCAT_WS SQL Server查询创建用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将项目连接在一起,而没有空格来为我的数据输出创建用户名.

下面是将在访问中工作的MS ACCESS查询.为了使其在MySQL中运行,我需要添加哪些调整?您如何串联SQL中的名字的首字母,中间名字和姓氏.我刚刚弄清楚了CONCAT_WS可以用来创建全名,如您所见.我应该为用户名使用相同的CONCAT_WS吗?如果是这样,如何获取它的首字母缩写?

I''m trying to concatenate items together with no spaces to create a username for my data output.

Below is the MS ACCESS query that will work in access. What adjustments do I need to add in order for it to run in MySQL? How do you concatenate the first initial, middle initial and last name in SQL. I just recently figured out the CONCAT_WS for creating a full name concatenate as you can see. Should I be using the same CONCAT_WS for the username? If so how do you get it to return the first initials?

"SELECT 
   			Customers.CustomerID, 
   			Customers.OldCustomerID,
   			CONCAT_WS( ', ',LastName,FirstName,MiddleName) AS CustomerName,


   			Left(FirstName,1)+Left(MiddleName,1)+LastName AS UserName,



   			zlu_Cars.Description AS Car, 
   			zlu_CarColor.Description AS CarColor, 
   			zlu_Computers.Description AS Computer, 

推荐答案

CONCAT_WS ((Left(FirstName,1)), (Left(MiddleName,1)), LastName) AS UserName,


这篇关于CONCAT_WS SQL Server查询创建用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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