如何在 Sql 服务器查询中使用 with 和 inner join?
how to use with and inner join in Sql server query?
为什么这个查询一定是错误的? :
with a as
(
select *
from justification_game_publisher
inner join justifications
on justifications.id = justification_id
where game_id=1594
)
select *
from games_publisher_class
inner join a
on a.game_id = games_publisher_class.game_id
and a.publisher_id = games_publisher_class.publisher_id
sql 服务器说:
Msg 319, Level 15, State 1, Line 2: Incorrect syntax near the keyword
'with'. If this statement is a common table expression, an
xmlnamespaces clause or a change tracking context clause, the previous
statement must be terminated with a semicolon.
我认为您之前还有其他 sql 表达。
尝试
;with a as (....
而不是
with a as (....
希望对您有所帮助:)
为什么这个查询一定是错误的? :
with a as
(
select *
from justification_game_publisher
inner join justifications
on justifications.id = justification_id
where game_id=1594
)
select *
from games_publisher_class
inner join a
on a.game_id = games_publisher_class.game_id
and a.publisher_id = games_publisher_class.publisher_id
sql 服务器说:
Msg 319, Level 15, State 1, Line 2: Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
我认为您之前还有其他 sql 表达。 尝试
;with a as (....
而不是
with a as (....
希望对您有所帮助:)