开发者

output table to obtain the rows

开发者 https://www.devze.com 2023-02-24 04:05 出处:网络
We want an output table to 开发者_JAVA技巧obtain the rows to simulate DB: SampleTable1 NameProduct JanBook

We want an output table to 开发者_JAVA技巧obtain the rows to simulate

DB:

SampleTable1

Name       Product

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


select * from SampleTable1

i would like result This Select Same Below output.

outPut:

Row        Name       Product  

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

In Access 2007


For Oracle you can do

select rownum as Row, Name, Product
  from SampleTable1;

For mySql:

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

For SQL Server:

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


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


In Mysql i think it would be like this:

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

精彩评论

暂无评论...
验证码 换一张
取 消