2011-09-27 140 views
0

我是SQL中的新手。我想在SQL中加入三個表。下面是我的查詢,請檢查並糾正我在哪裏,我錯了 -三張表加入SQL

表:

  • 卡:ID,代碼,名稱,CC
  • PGM:ID,代碼
  • PGMeCode:ID ,代碼,CC

查詢:

Select * 
FROM CARD 
INNER JOIN PGMeCode PGMeCode.Code = CARD.Code AND PGMeCode.CC = CARD.CC 
INNER JOIN PGM PGM.Code = Card.Code 
WHERE Card.ID = 'SomeThing' 

我不知道我做錯了什麼。請建議我!

在此先感謝。

回答

4

您錯過了表名後面的關鍵字ON

INNER JOIN tablename ON condition... 
0
SELECT * FROM CARD INNER JOIN PGMeCode ON PGMeCode.Code = CARD.Code AND PGMeCode.CC = CARD.CC INNER JOIN PGM ON PGM.Code = Card.Code WHERE Card.ID = 'SomeThing'; 

嘗試此查詢