想要结合last_name + first_name = company [英] Want to combine last_name + first_name= company

查看:82
本文介绍了想要结合last_name + first_name = company的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一些记录很好,例如

I'm getting some of the records good e.g

Last_Name:- COOKIES FASHION BOUT
First_Name:- IQUE
Company:- COOKIES FASHION BOUTIQUE



-------------------------------- ---

但在其他情况下


-----------------------------------
but in other case

Last_Name:- COOL TEXTILE IMPORT
First_Name:- LTD
Company :- COOL TEXTILE IMPORTLTD





但我需要的空间

COOL TEXTILE IMPORT LTD那里


需要修复这些记录..



我的尝试:





But I need the space between
COOL TEXTILE IMPORT LTD there

Need to fix these records..

What I have tried:

Select *, concat(Ltrim(Rtrim(Last_Name)),Ltrim(Rtrim(First_Name))) as Company from tbl
Go
--

推荐答案

Select *, Ltrim(Rtrim(Last_Name)) + ' ' + Ltrim(Rtrim(First_Name)) as Company from tbl





但是如果你是在其他地方显示此信息,如表单或网站,然后我将两列选为单独的字段,并在显示层中进行连接。



However if you're showing this information somewhere else like a form or a website then I'd select the two columns as separate fields and do the concatenation in the display layer.


您要么在考虑更改数据 - 添加一个特殊的字符,你可以随后用LTD前面的空格替换它们 - 或者添加特殊情况,你可以在这里找到像LTD,CO,PLC等特定的结尾,并特别留下空间。 />


就个人而言,我首先要看一下我从哪里获取数据,然后看看它是否可以在那里修复而不是以后使用它...它总是很乱在数据库中自动修复数据。
You are either looking at changing your data - adding a special characters that you later replace with a space in front of the LTD perhaps - or adding "special cases" where you look for specific endings like LTD, CO, PLC, and so on and specifically leave the spaces there.

Personally, I'd start by looking at where I got the data from, and see if it can be fixed there instead of later when it's used ... it's always messy to fix up data automatically once it's in your DB.


由于数据首先存储的方式,没有解决问题的方法。

有时你有时需要添加空间你没有,没有办法知道什么时候。



唯一的解决方案是在存储数据时不删除空格。
There is no solution to your problem because of the way data was stored in first place.
Sometimes you need to add a space, sometimes you don't, there is no way to know when.

The only solution is to not remove spaces when data is stored.


这篇关于想要结合last_name + first_name = company的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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