我正在尝试使用 join 语句进行查询。这就是我所拥有的:
SELECT Person.Id,
Person.AddressLine1, Person.AddressLine2, Person.Name,
Person.City
FROM Person WITH (NOLOCK) INNER JOIN
Customer ON
Customer.Id = Person.Id
WHERE (Person.IsRegular = 1)
但是当我使用它时(我在 WHERE 子句中添加了另一个参数):
SELECT Person.Id,
Person.AddressLine1, Person.AddressLine2, Person.Name,
Person.City
FROM Person WITH (NOLOCK) INNER JOIN
Customer ON
Customer.Id = Person.Id
WHERE (Person.IsRegular = 1) AND
(Customer.RoleType = 'XX') AND
(Customer.LocType = 3)
即使我的 Customer 表中有一行与 Person.Id 匹配,并且该特定行有一个 RoleType="XX" 和 LocType=3 的字段,也没有结果。
更新:修复了它,但现在我遇到了问题..我这样做了:
SELECT Person.Id, Person.AddressLine1, Person.AddressLine2, Person.Name, Person.City
FROM Person WITH (NOLOCK)
INNER JOIN Customer ON Customer.Id = Person.Id WHERE (Person.IsRegular = 1) AND (Customer.RoleType = 'XX') AND (Customer.LocType = 3)
AS xxx ON xxx.Id=1... it says:incorrect syntax near the keyword 'AS'