组合多个访问表中的数据以生成地址标签,优先选择邮政信箱而不是物理地址

发布于 2025-01-01 14:44:07 字数 507 浏览 1 评论 0原文

我有一个 Access 2007 数据库,其中有 3 个表,每个表都相同。

这些表中的每一个都供不同的电话营销人员输入潜在客户。有必要有多个表,因为每个营销人员必须被视为一个单独的实体。

每个表都有以下与问题相关的字段:

POBoxNumber
郊区邮政信箱
邮政信箱城
POBox邮政编码

地址构建
地址街道
地址郊区
地址城市
AddressPostCode

现在我需要做的是创建一个标签打印查询,该查询将优先使用邮政信箱而不是物理地址,如果邮政信箱为空,它将使用物理地址。

然后我需要将其显示为

AddrLine1
地址线2
地址线3
地址线4
AddrLine5

即AddrLine1,如果填写了pobox,则为邮政信箱号码,否则为建筑物...等等。

到目前为止,我已经尝试过联合和条件选择,但没有成功!

我该怎么做?

I have an Access 2007 database that has 3 tables, each the same.

Each of these tables is for a different telemarketer to enter leads. It is necessary for there to be multiple tables as each marketer must be treated as a separate entity.

Each of these tables has the following fields relevant to the question:

POBoxNumber
POBoxSuburb
POBoxCity
POBoxPostCode

AddressBuilding
AddressStreet
AddressSuburb
AddressCity
AddressPostCode

Now what I need to do is create a query for label printing which will prefer the PO Box to the physical address, if the PO Box is empty it will use the physical.

I then need this to be displayed as

AddrLine1
AddrLine2
AddrLine3
AddrLine4
AddrLine5

ie AddrLine1 if pobox is filled will be the PO Box number, otherwise it will be the building... and so on.

I have tried Unions and Conditional selects so far but to no avail!

How do I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

峩卟喜欢 2025-01-08 14:44:07

也许:

SELECT 
   t.POBoxNumber As AddrLine1,
   t.POBoxSuburb As AddrLine2,
   t.POBoxCity As AddrLine3,
   t.POBoxPostCode As AddrLine4,
   ""  As AddrLine5
FROM TheTable t 
WHERE t.POBoxNumber Is Not Null
UNION ALL
SELECT 
   AddressBuilding As AddrLine1,
   AddressStreet As AddrLine2,
   AddressSuburb As AddrLine3,
   AddressCity As AddrLine4,
   AddressPostCode As AddrLine5
FROM TheTable t 
WHERE t.POBoxNumber Is Null

如果这不是您想要的,请解释为什么不是,并提供一些示例数据。你的问题就目前而言有点模糊。

Perhaps:

SELECT 
   t.POBoxNumber As AddrLine1,
   t.POBoxSuburb As AddrLine2,
   t.POBoxCity As AddrLine3,
   t.POBoxPostCode As AddrLine4,
   ""  As AddrLine5
FROM TheTable t 
WHERE t.POBoxNumber Is Not Null
UNION ALL
SELECT 
   AddressBuilding As AddrLine1,
   AddressStreet As AddrLine2,
   AddressSuburb As AddrLine3,
   AddressCity As AddrLine4,
   AddressPostCode As AddrLine5
FROM TheTable t 
WHERE t.POBoxNumber Is Null

If this is not what you want, please explain why it is not and provide some sample data. Your question is a little vague as it stands.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文