Microsoft Jet 通配符:星号还是百分号?

发布于 2024-07-15 22:50:00 字数 414 浏览 3 评论 0原文

Microsoft Jet 中 LIKE 运算符中正确的多字符通配符是什么?什么设置会影响它(如果有)? 我支持一个在 Microsoft Jet(在 Access 数据库上)上运行的旧 ASP 应用程序,它在 LIKE 运算符中使用 % 符号,但我有一位客户在他的环境中显然存在问题,因为 % 字符被理解为常规字符字符,我假设他的多字符通配符是*。 另外,我几乎可以肯定,过去我编写过使用 * 而不是 % 进行查询的应用程序。 最后,Microsoft Access(作为应用程序)也仅适用于 * 而不是 % (但我不确定它的相关性如何)。

我只花了大约 20 分钟在互联网上搜索,没有任何有用的结果,所以我认为在 stackoverflow 上提问会很有用。 有人可能已经知道了,无论如何,最好将潜在的答案保留在 stackoverflow 上,而不是任何其他随机讨论论坛。

What is the proper multi-character wildcard in the LIKE operator in Microsoft Jet and what setting affects it (if any)? I am supporting an old ASP application which runs on Microsoft Jet (on an Access database) and it uses the % symbol in the LIKE operator, but I have a customer who apparently has problems in his environment because the % character is understood as a regular character, and I assume that his multi-character wildcard is *. Also, I'm almost sure that in the past I have written application with queries using * instead of %. Finally, Microsoft Access (as an application) also works only with * and not % (but I'm not sure how relevant it is).

I just spent about 20 minutes searching the Internet without any useful results, and so I thought it would be useful ask on stackoverflow. Somebody may already know it, and it's better to keep the potential answers on stackoverflow than any other random discussion forum anyway.

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

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

发布评论

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

评论(4

谎言 2024-07-22 22:50:00

直接的答案是通配符的行为取决于所使用的接口的 ANSI 查询模式。

ANSI-89 查询模式(“传统模式”)使用 * 字符,ANSI-92 查询模式(“SQL Server 兼容模式”)使用 % 字符。 这些模式是 ACE/Jet 特有的,与 ANSI/ISO SQL-89 和 SQL-92 标准仅有短暂的相似之处。

ADO 接口 (OLE DB) 始终使用 ANSI-92 查询模式。

DAO 接口始终使用 ANSI-89 查询模式。

使用 ODBC 时,可以通过 扩展AnsiSQL标志。

从 2003 版本开始,MS Access 用户界面可以使用任一查询模式,因此在任何给定时间都不要假定它是其中一种(例如,不要在验证规则中使用特定于查询模式的通配符)。

ACE/Jet SQL 语法有一个 ALIKE 关键字,无论查询模式如何,它都允许使用 ANSI-92 查询模式字符(%_)然而,该接口的一个小缺点是 ALIKE 关键字不兼容 SQL-92(但是 ALIKE 仍然具有高度可移植性)。 然而,主要的缺点是我知道 ALIKE 关键字不受官方支持(尽管我无法想象它会很快消失或改变行为)。

The straight answer is that the behaviour of the wildcard characters is dependent on the ANSI Query Mode of the interface being used.

ANSI-89 Query Mode ('traditional mode') uses the * character, ANSI-92 Query Mode ('SQL Server compatibility mode') uses the % character. These modes are specific to ACE/Jet and bear only a passing resemblance to the ANSI/ISO SQL-89 and SQL-92 Standards.

The ADO interface (OLE DB) always uses ANSI-92 Query Mode.

The DAO interface always uses ANSI-89 Query Mode.

When using ODBC the query mode can be explicitly specified via the ExtendedAnsiSQL flag.

The MS Access user interface, from the 2003 version onwards, can use either query mode, so don't assume it is one or the other at any given time (e.g. do not use query-mode-specific wildcard characters in Validation Rules).

ACE/Jet SQL syntax has an ALIKE keyword, which allows the ANSI-92 Query Mode characters (% and _) regardless of the query mode of the interface, however has the slight disadvantage of the ALIKE keyword not being SQL-92 compatible (however ALIKE remains highly portable). The main disadvantage, however, is that I understand the ALIKE keyword is not officially supported (though I can't imagine it will disappear or have altered behaviour anytime soon).

旧伤慢歌 2024-07-22 22:50:00

如果您使用 DAO,请使用星号(以及单个符号占位符的问号)。 如果您使用 ADO,请使用百分号(和下划线)。

If you're using DAO, use asterisk (and question mark for single symbol placeholder). If you're using ADO, use percent sign (and underscore).

挽袖吟 2024-07-22 22:50:00

您可能会发现这很有用:

http://msdn.microsoft .com/en-us/library/aa140104(office.10).aspx

在查询设计网格中,对于 DAO,您使用 *,对于 ADO 和 ASP,您使用 %

You may find this useful:

http://msdn.microsoft.com/en-us/library/aa140104(office.10).aspx

In the query design grid and with DAO you use *, with ADO and ASP, you use %

初雪 2024-07-22 22:50:00

通过 ODBC 访问 Jet,我不清楚应该使用什么通配符。 我假设自然的 Jet SQL 数据(*/?),但由于我从未通过 ODBC 使用 Jet 数据,所以我不能说。

在 Access 中,正如 Remou 引用的文章所说,在代码中,这取决于您使用的数据访问接口 - ADO(没有人应该在 Access 中使用),您使用 %/_ ,而使用 DAO(Jet 的本机接口层) ),您使用 Jet 的本机通配符 (*/?)。

在 Access 中执行 SQL 的更高版本的 Access 中存在异常。 我不知道是 Access 2002 还是 2003 添加了它,但是现在,有一个 ANSI SQL 92 兼容模式可以打开。 如果这样做,通配符将变为 %/_ 而不是 */?。 但能够选择 ANSI 模式仅适用于 Access 本身 - 正如 onedaywhen 告诉我们的那样,您必须选择不同的数据接口库才能使用不同的 SQL 模式,其中 ADO 使用 92,DAO 和 ODBC 89。

Accessing Jet via ODBC, it's not clear to me what wildcards should be used. I'd assume the natural Jet SQL ones (*/?), but since I never use Jet data via ODBC I can't say.

Within Access, as the article Remou cites says, in code, it depends on what data access interface you use -- ADO (which nobody should be using from within Access), you use %/_ , while with DAO (Jet's native interface layer), you use Jet's native wildcards (*/?).

There is an exception in later versions of Access executing SQL within Access. I don't know if it was Access 2002 or 2003 that added it, but nowadays, there is an ANSI SQL 92 compatibility mode that you can turn on. If you do that, the wildcards become %/_ instead of */?. But being able to choose the ANSI mode applies only within Access itself -- as onedaywhen has informed us, you have to choose different data interface libraries to use the different SQL modes, with ADO using the 92 and DAO and ODBC 89.

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