简体   繁体   English

临时表-内部联接

[英]Temp table -inner join

I wrote this query to inner join the temp table with another SQL table: 我编写了此查询,以将临时表与另一个SQL表进行内部联接:

(SELECT 
id FROM
  #Temp WHERE code<>10
)AS s inner join table1 r on s.id=r.id)

I'm getting an error: 我收到一个错误:

Incorrect syntax near the keyword 'AS'. 关键字“ AS”附近的语法不正确。

Can someone help me on this? 有人可以帮我吗?

The only sense I can make of your code is a query like this: 我对您的代码的唯一理解就是这样的查询:

SELECT s.id
FROM #Temp s JOIN
     table1 r 
     ON s.id = r.id
WHERE s.code <> 10;
select s.id, r.* 
from
(SELECT id 
 FROM #Temp 
 WHERE code<>10
) s 
inner join table1 r on s.id=r.id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM