输出表来获取行

时间:2011-04-10 18:36:11

标签: ms-access

我们希望输出表获取要模拟的行

DB:

SampleTable1

Name       Product

 Jan         Book
 Smith       Glass
 ....        .....


select * from SampleTable1

我想结果这个选择相同的输出。

输出:

Row        Name       Product  

  1          Jan         Book          
  2          Smith       Glass
  3          ....        .....

在Access 2007中

3 个答案:

答案 0 :(得分:2)

对于Oracle,您可以

select rownum as Row, Name, Product
  from SampleTable1;

对于mySql:

select @rownum := @rownum + 1 as Row, Name, Product
  from SampleTable1, (select @rownum := 0)

对于SQL Server:

select row_number() over (order by Name) as Row, Name, Product
  from SampleTable1

答案 1 :(得分:0)

SELECT Name, Product, row_number() OVER (ORDER BY Name) AS Row
  FROM SampleTable1 

答案 2 :(得分:0)

在Mysql中我认为会是这样的:

select @rownum:=@rownum+1 slno, s.* from SampleTable1 s, (SELECT @rownum:=0) r