Hello: When I call up a specific record, I need to sort the contents of "tblpartmanuf" and replace that field with the sorted information. Lets say the record is: tblpartnumber tblpartmanuf 12544 GFSD After I edit some other fields, automatically sort the tblpartmanuf field so that it is: 12544 DFGS $sql="SELECT tblpartnumber, tblpartmanuf FROM tblparts WHERE tblpartnumber ='$frmpartfinder'"; $result = mysql_query($sql) or die('Error: ' . mysql_error());
i have not seen any SQL function which will do this. But one way to do this is to create your own function. Basically you write the code for your function and call it from your sql. your function accepts the tblpartmanuf and returns the name after sorting. So your SQL query will return values after sorting. your SQL should look like this: $sql="SELECT tblpartnumber, f_sortmanuf(tblpartmanuf) FROM tblparts WHERE tblpartnumber ='$frmpartfinder'";
Either process all records once and for all by php script for performance reasons OR do string sort in php, again for performance reasons. I would advice not to try such operations in mysql, which are anyways not to be done there unless extremely needed.
1) We have no idea whether this is MySQL or some other database. 2) There's nothing wrong with a little sort function in TSQL - we run queries daily that are composed of tens of thousands of lines of TSQL, with MUCH larger functions. How efficient that is depends on the database. In Access? Forget it. In Oracle or RDB? That's how they're used.
I assumed it to be MySQL from the code written at last in OP. $sql="SELECT tblpartnumber, tblpartmanuf FROM tblparts WHERE tblpartnumber ='$frmpartfinder'"; $result = mysql_query($sql) or die('Error: ' . mysql_error()); PHP: