简体   繁体   English

SQL Server为什么关键字'select'附近的语法不正确

[英]SQL Server why Incorrect syntax near the keyword 'select'

select *
from 
    (select * 
     from 
         (select t1.stdid
         from t1) as table1
     cross join 
         select * 
         from 
             (select t2.Subid
              from t2) as table2
    ) as table3

Try the query below. 请尝试以下查询。 You included an addition select * from that you should have left out. 您添加了一个应该省略的选择*。

select *
from (
 select * 
 from (
    select t1.stdid
    from t1
    ) as table1
cross join 
-- select * from : This line is extraneous and is causing your error.
   (
    select t2.Subid
    from t2
    ) as table2
) as table3

Alternatively, you will get the same result if your query was written as: 或者,如果您的查询写为:

 select * 
 from (
    select t1.stdid
    from t1
    ) as table1
cross join 
   (
    select t2.Subid
    from t2
    ) as table2

Please don't use * in the query. 请不要在查询中使用*。 Just select the column which you want.Please see below: 只需选择所需的列即可,请参见以下内容:

select ID
from 
    (select t1.id as ID
     from 
         (select t1.id
         from t1) as t1
     cross join 

             (select t2.id
              from t2) as t2
    ) as table3

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

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