您好我试图创建一个查询只显示具有相同3个字母的邮政编码,但是,它根本不返回任何内容。这是我的代码:
SELECT Custtbl.Name, Custtbl.PostCode
FROM Custtbl
Where (((Custtbl.PostCode)=Left([PostCode],3)))
任何帮助将不胜感激!
答案 0 :(得分:1)
这是:
SELECT DISTINCT
Custtbl.Name,
Custtbl.PostCode
FROM
Custtbl,
Custtbl As T
WHERE
Custtbl.Name <> T.Name
AND
Left(Custtbl.PostCode, 3) = Left(T.[PostCode], 3)
答案 1 :(得分:0)
您缺少Custtbl.PostCode上的Left功能。您的查询应该是
SELECT Custtbl.Name, Custtbl.PostCode
FROM Custtbl
Where ((LEFT(Custtbl.PostCode,3)=Left([PostCode],3)))
答案 2 :(得分:0)
我认为你正在寻找LIKE条件。 TutorialPoint
SELECT Custtbl.Name, Custtbl.PostCode
FROM Custtbl
Where (Custtbl.PostCode LIKE Left([PostCode],3) + '%')
这将返回[PostCode]中前3个字符与Custtbl.PostCode中前3个字符匹配的任何行