关于取第一条数据的sql特此作了一个例子如下:
SELECT * FROM tableName where fd_rt = 'A'
标题
正常说 第一条数据应为 16bf4eb91606de5e0ff61f94d0f8f20f
在where 后 直接跟条件 使用此sql时结果如下
SELECT * FROM tableName where fd_rt = 'A'
![](http://image109.360doc.com/DownloadImg/2022/10/1022/253899983_2_20221010102612978.png)
可是查询结果为 第二条数据
正确使用方式为:
SELECT * FROM tableName where fd_rt = 'A' ORDER BY fd_date DESC
![](http://image109.360doc.com/DownloadImg/2022/10/1022/253899983_3_20221010102613102.png)
rownum作为伪列实际上查询结果为:
SELECT tableName .*,rownum FROM tableName where fd_rt = 'A'
![](http://image109.360doc.com/DownloadImg/2022/10/1022/253899983_4_20221010102613164.png)
SELECT * FROM tableName where fd_rt = 'A' ORDER BY fd_date DESC
![](http://image109.360doc.com/DownloadImg/2022/10/1022/253899983_5_20221010102613211.png)
|