我想使用連接語句進行查詢。這是我有:SQL連接查詢不返回任何東西
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)
有沒有結果,即使我有一個排在我的客戶表匹配Person.Id並且該特定行具有RoleType =「XX」和LocType = 3的字段。
UPDATE: 固定的,但現在我有一個問題..我這樣做:
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'
是否與特定是PersonID的角色類型「XX」的人,LOCTYPE 3具有屬性IsRegular集到1? – SchmitzIT 2012-07-18 08:09:18
是否有你使用'WITH(NOLOCK)'的原因? – 2012-07-18 08:10:19
請發佈您的表格數據。 – SMK 2012-07-18 08:10:37