可能重复,但不提供此案例的见解: The multi-part identifier could not be bound
我查询了以下表格:
select l.id, l.foo, r.id, r.foo
from tbl l
inner join storyevents r on l.id = r.id
right join (
select distinct foo from tbl where id= l.id
) tmp on l.foo = tmp.foo
where l.foo = 12345
但我收到以下错误:
The multi-part identifier "l.id" could not be bound.
与right join
子查询有关。
奖励积分:
这是尝试根据单个列从inner join
中删除重复的行。更好的方法吗?
答案 0 :(得分:1)
试试这个,
SELECT l.id, l.foo, r.id, r.foo
FROM storyevents l
INNER JOIN storyevents r
ON l.id = r.id
RIGHT JOIN
(
SELECT distinct extid, foo
FROM storyevents
) tmp on l.foo = tmp.foo AND
tmp.extid = l.id
where l.foo = 12345
答案 1 :(得分:0)
删除重复行的更好方法是什么?
select distinct l.id, l.foo, r.id, r.foo
....