自己用mybatis进行动态排序的时候发现排序并没有实现,代码如下:
select rownum num,a.* from from bto_c3.bkr_orderpackage_all a
order by #{toptype} desc
where rownum < 11
#是将传入的值当做字符串的形式,eg:select id,name,age from student where id =#{id},当前端把id值1,传入到后台的时候,就相当于 select id,name,age from student where id =‘1’.
$是将传入的数据直接显示生成sql语句,eg:select id,name,age from student where id =${id},当前端把id值1,传入到后台的时候,就相当于 select id,name,age from student where id = 1.
所以这里需要注意,应该将#改为$:
select rownum num,a.* from from bto_c3.bkr_orderpackage_all a
order by ${toptype} desc
where rownum < 11