使用没有指定条件的where子句 [英] using where clause without specified criteria

查看:95
本文介绍了使用没有指定条件的where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含以下内容的Access数据库:



 SEG,AMK,101427Y,EG3902,EG3902-G1 
SEG,AMK,101427Y,EGS650,EGS650-G1
SEG,AMK,103852S,EG3901,EG3901-G1
SEG,AMK,103852S,EG3904,EG3904-G1
SEG,AMK, 103852S,EGS104,EGS104-G1
SEG,AMK,103852S,EGS650,EGS650-G1
SEG,AMK,106581C,EG3901,EG3901-G1
SEG,AMK,106581C,EG3902,EG3902 -G1
SEG,AMK,111713M,EG3901,EG3901-G1
SEG,AMK,111713M,EG3902,EG3902-G1





列标题:学校,校园,AdminNo,ModuleCode,ModuleGrp







<我希望检索不同数据的模块代码是
。我知道如何使用select distinct来获取不同的数据

i希望将2个列放入datagridview,moduleCode和AdminNo

输出应该是这样的:



ModuleCode AdminNo

EG3901 --- 12344Y

----------- 23456H



EG3902 --- 64738U

----------- 99393J

------ ----- 63738B











我知道设置标准,例如country = mexico

但是现在,我无法列出所有ModuleCodes,因为数据随文件的变化而变化,并且有超过30k的记录。



谢谢!

解决方案

DISTINCT是使用的关键词,它可以无任何工作WHERE子句。

  SELECT   DISTINCT  ModuleCode ,AdminNo 
FROM MYTABLE
ORDER BY ModuleCode ASC ,AdminNo ASC


i have a Access database containing the following:

SEG,AMK,101427Y,EG3902,EG3902-G1
SEG,AMK,101427Y,EGS650,EGS650-G1
SEG,AMK,103852S,EG3901,EG3901-G1
SEG,AMK,103852S,EG3904,EG3904-G1
SEG,AMK,103852S,EGS104,EGS104-G1
SEG,AMK,103852S,EGS650,EGS650-G1
SEG,AMK,106581C,EG3901,EG3901-G1
SEG,AMK,106581C,EG3902,EG3902-G1
SEG,AMK,111713M,EG3901,EG3901-G1
SEG,AMK,111713M,EG3902,EG3902-G1



column headings: School, Campus, AdminNo, ModuleCode, ModuleGrp




for the module code i wanna retrieve the distinct data. I know how to obtain distinct data using select distinct
i want to put into datagridview with 2 columns, moduleCode and AdminNo
the output should be like:

ModuleCode AdminNo
EG3901---12344Y
-----------23456H

EG3902---64738U
-----------99393J
-----------63738B

.
.
.

im aware of setting criteria like country=mexico
but right now, i cant list out all the ModuleCodes as the data varies as the file changes, and there are over 30k records.

Thanks!

解决方案

DISTINCT is the key word to use, and it can work without any WHERE clause.

SELECT DISTINCT ModuleCode, AdminNo
FROM MYTABLE
ORDER BY ModuleCode ASC, AdminNo ASC


这篇关于使用没有指定条件的where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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