eva21 Posted August 12, 2008 Share Posted August 12, 2008 Usually saving in a database, you have the field, and than the ID. Now since SQL increments on its own for example: 1, 2, 3,4 etc...usually when you call that certain table it displays as 1 - whatever 2 - whatever2 3 - whatever3 4 - whatever4 Unless specified. Now if I let the user to chance the fields around, and so now i need to it to show up like the following: 4 - whatever4 2 - whatever2 1 - whatever 3 - whatever3 What kind of SQL Statement would i do? I would have to do an UPDATE, but how could i make it save it in that order in the database? Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 12, 2008 Share Posted August 12, 2008 you'd need to do an update for each individual item, and what the query would actually look like is completely dependent upon the form you're using to let them change the order. for the record, IDs are used to maintain referential integrity. if you're just wanting to use it to order your results, you're better off just using an otherwise-named ("display_order" or something similar) with an INT format. primary keys shouldn't be used for dictating display order. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.