select 喜欢 ms 访问查询中的前 3 位数字

select LIKE first 3 digits in ms access query

如何将下面的查询调整为return区号为765的记录?

请注意,mytable table 有一个电话字段,其中的数字格式为 xxxxxxxxxx,其中前三位数字是区号。这是当前 SQL,它没有 returning 任何记录:

SELECT *
FROM mytable
WHERE Telephone LIKE '765%';

您可以使用left函数。

SELECT *
FROM mytable
WHERE left(Telephone,3) = '765'

在 MS-Access 中,通配符是 *,而不是 ANSI SQL 规定的 %。因此,您的查询应该是:

SELECT *
FROM   mytable
WHERE  Telephone LIKE '765*';

有关其他详细信息,请参阅 the documentation