Ahmed Ahmed - 1 month ago 9
SQL Question

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

Answer Source

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

Additionally, you will get the same result if your query was be written as:

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