MS Access 2003 中 IN 子句中的元组

发布于 2025-01-06 20:37:23 字数 543 浏览 4 评论 0原文

我想在MS Access 2003(或者只是VBA中的sql)中进行查询,该查询将有一个IN子句处理元组,即,

我必须包含列,并且我想使用IN子句提取例如2010-10和2012-03。为了在 Postgres 中进行比较,它看起来像

SELECT * FROM my_table WHERE (year, month) IN (("2010","10"),("2012","03"));

,但在 Access 中对我不起作用。是的,我将年份和月份都存储为文本,但这并不重要。

我知道我可以使用许多 ANDOR 来编写它,或者使用临时表进行 LEFT JOIN 。但这些查询是通过编程方式创建的,所以我想让它尽可能简单。

I wanted to make a query in MS Access 2003 (or just sql in VBA) which would have an IN clause working on tuples, i.e.,

I have to columns with year and month, and I would like to extract for example 2010-10 and 2012-03 using IN clause. For comparison in Postgres it would look like

SELECT * FROM my_table WHERE (year, month) IN (("2010","10"),("2012","03"));

but it does not work for me in Access. Yes, I store both year and month as text, but it really does not matter.

I know I could write it using many AND and OR, or make a LEFT JOIN with a temporary table. But those queries are created prograYmatically, so I wanted to make it as simple as possible.

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

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

发布评论

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

评论(1

满身野味 2025-01-13 20:37:23

怎么样:

SELECT * FROM my_table WHERE year & month IN ("201010","201203")

How about:

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