开发者

Three tables join in SQL

开发者 https://www.devze.com 2023-04-09 04:17 出处:网络
I am newbie in SQL. I want to join three tables in SQL. Below is my query, please check and correct me where I am wrong -

I am newbie in SQL. I want to join three tables in SQL. Below is my query, please check and correct me where I am wrong -

Tables:

  • CARD: ID,Code,Name,CC
  • PGM: ID,Code
  • PGMeCode: ID,Code,CC

Query:

Select *
FROM CARD
INNER JOIN PGMeCode PGMeCode.C开发者_如何转开发ode = CARD.Code AND PGMeCode.CC = CARD.CC
INNER JOIN PGM PGM.Code = Card.Code
WHERE Card.ID = 'SomeThing'

I don't know what I am doing wrong. Please suggest me!!

Thanks in advance.


You are missing the keyword ON, placed after the table name.

INNER JOIN tablename ON condition...


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';

Try this query

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号