简体   繁体   English

有条件地在Access SQL中创建数字列表

[英]Conditionally creating a list of numbers in Access SQL

This is a homework task for Microsoft Access 2010. 这是Microsoft Access 2010的家庭作业任务。
How to create a query that will return a list of numbers from 1 to 18? 如何创建一个返回1到18的数字列表的查询? Though on one condition, that the list of numbers will not contain any number that exists in table A. 虽然在一个条件下,数字列表将不包含表A中存在的任何数字。

So for example. 所以举个例子。 Table A has 1, 5, 10, 8, and 16. Therefore, the query will only return this list of numbers (2, 3, 4, 6, 7, 9, 11, 12, 13, 14, 15, 17, 18) 表A有1,5,10,8和16.因此,查询只返回这个数字列表(2,3,4,6,7,9,11,12,13,14,15,17, 18)

Would anyone be kind enough to shed some pointers? 有人会善意地提出一些指示吗? Thanks. 谢谢。

SQL is a set-based language. SQL是一种基于集合的语言。 So you are always working with intersections, unions, complements, etc. 所以你总是在处理十字路口,工会,补充等。

Consider that Table A could be completely empty. 考虑表A可能完全是空的。 In this case you need to return all the numbers from 1 to 18. You are going to need to get these numbers from somewhere. 在这种情况下,您需要将所有数字从1返回到18.您需要从某个地方获取这些数字。 (Hint, how about creating another table?) (提示,如何创建另一个表?)

Once you can write a query returning all the numbers from 1 to 18, you can start thinking about getting all the numbers from 1 to 18 EXCEPT those in table A. 一旦你可以编写一个从1到18返回所有数字的查询,你可以开始考虑从1到18获得所有数字,除了表A中的数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM