asp.net c# sql问题

来源:百度知道 编辑:UC知道 时间:2024/05/24 19:09:12
这种查询怎么不支持了
select * from (select * from 表)
=====================================
string sql = "select top 1 * from [info]";
SqlDataAdapter sda = new SqlDataAdapter(sql, my.Conn);
DataSet ds = new DataSet();
sda.Fill(ds, "Tname");

上面那段代码是好使的,可把sql换为select top 1 * from (select top 2 * from Info)就不好使了,为什么啊?怎么解决呢?
====================================

select top 1 * from (select top 2 * from Info) as a
指定一个别名,不然有语法错误

格式不对,select top 1 * from 表名 where 字段 in (select top 2 * from info ),from后一定是表名的,where后才能有集合和条件。

经过验证一楼回答正确