sql语句Order by 报错列名不明确

select top 10 column1,column2,column3 from table1 where table1.id not in(select top 0 table1.id from table1 order by column1 asc) order by column1 asc

注意这种写法会报错  列名 'column1' 不明确

在查下时不把列名写出来,用* 就不会报错,目前还不知道原因,有知道的请指点

select top 10 * from table1 where table1.id not in(select top 0 table1.id from table1 order by column1 asc) order by column1 asc

这样就不会报错了

原文地址:https://www.cnblogs.com/yubufan/p/6898399.html