Skip to main content

mysql order by and bind params

We use a grid to show files and when user clicks on a header we sort it.

I was using a statement like "order by :orderBy :sortDirection" and binding it in sql using spring but it was not doing any sorting.

After spending 1+hours on it I found out that mysql doesnt support bind parameters in order by and direction, yikes.

This is second weird thing I noticed in 1 day. The other thing I noticed was mysql doesnt support multicolumn updates

you cant do

update files set (size,ctime)=(select ctime,size from versions where versions.file_id=files.file_id) where file_id=:xxx

aparently you need to do a join query in update which makes the query very weird.

But even with issues Mysql rocks in performance.

Comments