php mysql查询表中最后设置的行数

时间:2012-05-12 05:24:05

标签: php mysql sql

我想构建一个mysql_query,只会在rows中插入一个新的table,其中where condition就像...... {/ p>

SELECT (LAST 5) FROM `x`  WHERE `USER_KEY` = '$RK' ORDER BY `dd` DESC 

此数据将在json中解析,否则我将获得所有数据并循环投掷。

1 个答案:

答案 0 :(得分:2)

你可以撤销订单并获得第一个5.这与获得最后5个并以相反方式排序相同

SELECT * FROM `x`  WHERE `USER_KEY` = '$RK' ORDER BY `dd` ASC limit 5

或者如果你需要desc命令,你可以做

select * from (SELECT * FROM `x`  
               WHERE `USER_KEY` = '$RK' 
               ORDER BY `dd` asc 
               limit 5) as x 
order by `dd` desc