无法理解此SQL查询中的错误:
USE [My_db]
GO
SELECT ItemId
,Subject
,CreatedOn
FROM ItemBase AS e
INNER JOIN ItemExtensionBase AS p
ON e.ItemId = p.ItemId
GO
错误:
Msg 209, Level 16, State 1, Line 4
Ambiguous column name 'ItemId'.
两个表中都存在 ItemId
列。
答案 0 :(得分:4)
USE [My_db]
GO
SELECT e.ItemId
,Subject
,CreatedOn
FROM ItemBase AS e
INNER JOIN ItemExtensionBase AS p
ON e.ItemId = p.ItemId
GO
您需要告诉它从
中取出itemid字段的表答案 1 :(得分:3)
使用e.ItemId
或p.ItemId
:
USE [My_db]
GO
SELECT e.ItemId
,Subject
,CreatedOn
FROM ItemBase AS e
INNER JOIN ItemExtensionBase AS p
ON e.ItemId = p.ItemId
GO