6 December 2004

Maintain a sortorder column

Who knew I would find FIND_IN_SET so useful.

It is not uncommon to have a sort column, for alternative ways to sort data. Recently a client requested a GUI to change sort order of how “data” is returned to their end user.

Using my new found knowledge of “FIND\_IN_SET” which I spoke about in the Sort by specific ID, I quickly whipped up a HTML/Javascript GUI that allows users to move items up and down in a select list…

When they are happy they can submit… and sortorder column reflects how they feel data should be ordered.

Here is the SQL code that is run … where “1,2,3, ....” is the order that user wants.

UPDATE TABLE tablename
SET sortordercol = FIND\_IN_SET(id, "1,2, 3...") 
 

Comment



note: you can only submit after you hit preview


nuff-respec is a weblog written by daniel bulli a senior web programmer in boston, ma.
more >

contact | resume | profile | twitter

recently :::