比较同一表中多个列/行中的数据与查询 [英] Comparing data in multiple columns/rows in same table with query

查看:69
本文介绍了比较同一表中多个列/行中的数据与查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含2列的表,我需要数据库才能匹配。我有一群人列出了他们在一栏中的内容,在下一栏中列出了他们想要的内容。我需要数据库告诉我哪些匹配。


约翰尼有一个苹果但想要一个橙色

莎莉有一个橙子但想要一个苹果

Derek有一个梨,但想要一个香蕉。


在上面的场景中,数据库会告诉我比赛是Johnny和Sally,因为他们都有其他想要的。 Derek不会出现,因为他没有一个想要梨的人。可怜的Derek :-(


表名:FODEIDE18交换请求

栏目:

ID

ROM

排名

姓名

目前的学校选择

交换学校申请

优先顺序

DT功能区


我需要DB来比较当前的学校选择和交换学校请求


任何帮助你可以提供的将是惊人的!

I have a table that has 2 columns that I need the Database to match. I have a bunch of people that have listed what they have in one column and in the next column, they list what they want. I need the Database to tell me which ones match.

Johnny has an apple but wants an orange
Sally has an orange but wants an apple
Derek has a pear, but wants a banana.

In the above scenario, the Database would tell me that the matches are Johnny and Sally because they both have what each other wants. Derek would not show up since he didn''t have a person that wanted a pear. Poor Derek :-(

Table name: FODEIDE18 Exchange Requests
Columns:
ID
ROM
Rank
Name
Current School Selection
Exchange School Request
Priority
DT Functional Area

I need the DB to compare Current School Selection and Exchange School Request

Any assistance you can provide would be amazing!

推荐答案

为什么不命名这个列,并像这样引用它们我有一群人列出他们有什么在一栏和下一栏中,他们列出了他们想要的东西。?


当你有一张桌子时( ''Table1'')包含以下字段:
Why not name this columns, and refer to them like this "I have a bunch of people that have listed what they have in one column and in the next column, they list what they want."?

when you have a table (''Table1'') with these fields:
展开 | 选择 | Wrap | 行号


我不认为这就那么简单。

当菲尔还有一个橙子但想要一个苹果时会发生什么?所以Sally& Phil匹配Johnny。


另外,请尽量避免使用对象名称(表格,查询,表格和报告)以及字段名称中的空格。此外,ID作为字段名称不会告诉您该字段 - RequestID可能更好。此外,如果你想避免作家的抽筋,保持名称简短但有意义。 拥有有什么问题?和请求?


Phil
I don''t think it''s as simple as that.
What happens when Phil also has an orange but wants an apple? So both Sally & Phil match Johnny.

As an aside, try to avoid spaces in Object Names (Tables, Queries, Forms & Reports) and also in field names. Also ID as a field name tells you nothing about the field - RequestID might be better. Also, if you want avoid writers'' cramp, keep names short but meaningful. What is wrong with "Owned" and "Requested"?

Phil


@PhilWalton:你是对的,这只是得到 j1s15n <的快速答案/ b>开始了,现在让我们等待 j1s15n
@PhilWalton: you are right, this was just a quick answer to get j1s15n started, now let''s wait for j1s15n


这篇关于比较同一表中多个列/行中的数据与查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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