将多行上的匹配地址组合到一行上 [英] combine matching addresses on multiple lines onto one line

查看:69
本文介绍了将多行上的匹配地址组合到一行上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改以下代码,以显示每行上的所有客户名称,将具有相同地址的客户合并到一行,同时留下不单独复制地址的客户。

I am trying to modify the following code from showing all customer names on each line to combining customers with same address onto one line, while leaving the customers who are not duplicating address alone.

展开 | 选择 | Wrap | 行号

推荐答案

我认为从长远来看你要做的是看看重组表格,以便数据是不重复开始......换句话说,规范化表结构。您可以这样做的一种方法是使用一个表来存储每个地址一次只有一个地址ID,一个客户表只存储客户及其相应的地址ID。然后你可以将两者连接在地址ID上,这样可以更容易地编写SQL。


Pat
I think what you want to do in the long run is take a look at restructuring the tables so that data is not duplicated to begin with...in other words normalize the table structure. One way that you could do this would be to have a table that stores each address just once with an address ID, and a customer table that stores just customers with their corresponding address ID. You can then join the two together on the address ID, which should make writing the SQL easier.

Pat


ZeppHead的观点是制作精良,绝对值得关注。但是,仍然存在相同的基本问题,因为名称需要连接以满足您的需求。 合并行 - 相反的联盟可能会有所帮助。请记住,您的请求并不是简单地连接条目,因为先生/女士/小姐/等数据的处理方式不同(您没有详细解释如何)。你需要自己处理这个逻辑。


有关数据库设计的信息你可能比查找更糟糕规范化和表结构
ZeppHead''s point is well made and absolutely worth following. However, there is still the same fundamental issue remaining as the names would need to be concatenated to do what you require. Combining Rows-Opposite of Union may help with that. Bear in mind that your request isn''t simply concatenationg the entries, as the Mr/Mrs/Miss/etc data is handled differently (You haven''t explained exactly how). You''ll need to handle that logic yourself.

For info on database design you could do a lot worse than look up Normalisation and Table structures.


@ brat33


如果重组和/或规范化不是可行的选项,那么有一个基于代码的解决方案,但它在很大程度上依赖于地址完全相同,而不是因子分解在城市,州等。例如,下面的所有地址都指的是相同的物理位置,但在测试平等时不会被视为相同。如果你想继续这些,请告诉我。
@brat33
If Restructuring and/or Normalizing are not viable Options, there is a code based solution, but it relies heavily on the Addresses being exactly the same, and not factoring in City, State, etc. Case in point, all the Addresses below refer to the same physical Location but would not be considered equal when tested for equality. If you wish to proceed along these lines, let me know.
展开 | 选择 | Wrap | 行号


这篇关于将多行上的匹配地址组合到一行上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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