如何在MS Access中使用非重复 [英] how to use distinct in ms access

查看:68
本文介绍了如何在MS Access中使用非重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个桌子.任务和类别.

I have two tables. Task and Categories.

TaskID不是主键,因为存在重复的值.当为一个特定任务选择多个联系人时,taskid和其他详细信息将被复制.我编写了查询:

TaskID is not a primary key as there are duplicate values.When there are multiple contacts are selected for a specific task,taskid and other details will be duplicated.I wrote the query:

SELECT Priority, Subject, Status, DueDate, Completed, Category
FROM Task, Categories
WHERE Categories.CategoryID=Task.CategoryID;

现在为该任务选择了多个联系人,对于taskid = T4,有两个记录(以灰色突出显示).我曾尝试在MS Access 2003中使用distinct,但无法正常工作.我想显示不同的记录. (这里不需要显示taskid)如果我写:

Now as multiple contacts are selected for that task,for the taskid=T4, there are two records(highlighted with gray). I have tried using distinct in ms access 2003 but its not working. I want to display distinct records. (Here there's no requirement to show taskid) If I write :

select priority, distinct(subject), .......

并保持与上面查询中提到的相同,然后给我一个错误.我也尝试过distinctrow.但是没有成功.如何在ms访问中获取不同的值?

and remaining same as mentioned in above query then its giving me an error. I have tried distinctrow also.But didnt get success. How to get distinct values in ms access?

推荐答案

好的.它是这样工作的.

Okay.Its working this way.

SELECT DISTINCT Task.Priority, Task.Subject, Task.Status, Task.DueDate, 
Task.Completed, Categories.Category
FROM Task, Categories
WHERE (((Categories.CategoryID)=[Task].[CategoryID]));

这篇关于如何在MS Access中使用非重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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