我现在有这样的SQL语句采用分页查询:
SELECT a.id,a.artist_cnname,a.artist_enname, CONCAT(is_actor,is_director) rmk, a.optdate,a.optname, GROUP_CONCAT(f.film_cnname) film_name
FROM artist a LEFT JOIN film_artist fa ON a.id=fa.artist_id LEFT JOIN film f ON fa.film_id=f.id where a.artist_cnname in ( ?,?)
GROUP BY fa.artist_id
order by field(a.artist_cnname, ?,?)
Model在分页过程中,查询总个数生成totalRowSql:
select count(*) FROM artist a LEFT JOIN film_artist fa ON a.id=fa.artist_id LEFT JOIN film f ON fa.film_id=f.id where a.artist_cnname in ( ?,?)
GROUP BY fa.artist_id
这个语句去除了 order by 的内容,然而,我的order by 查询中包含参数,查询过程中造成错误Parameter index out of range。
除了直接在 order by 后面拼接内容外,还有其他方法解决这类问题嘛?