0

Mysql query when checked in phpmyadmin works without errors and changes are seen in the table, but when the phpmyadmin is refreshed it doesn't show changes.This query is written to sort the records in alpha numeric as order, when query written in PHP changes is shown but soon reverts back to the same unorderly table present before. I need it to arrange it in order

  A1
  A2
  .
  .
  B1 
  B2
  .
  . 
  C1 and so on.. 

      SELECT *FROM `supactive1` ORDER BY
      CAST(Tno AS UNSIGNED)=0,
      CAST(Tno AS UNSIGNED), 
      LEFT(Tno,1),
      CAST(MID(Tno,2) AS UNSIGNED);
Nagaraj S
  • 13,316
  • 6
  • 32
  • 53

2 Answers2

0

When running this query in phpMyAdmin or via your PHP script, you are seeing the results of this query. The query is simply a SELECT query and as such won't make changes to the table(s), but will return a result set which you are seeing.

flauntster
  • 2,008
  • 13
  • 20
  • The 2nd answer here shows how it can be done, but it's a bit of work & I'm unsure why you would need to do it, if you can order the output as you are already. http://stackoverflow.com/questions/1850594/mysql-how-to-reorder-a-table?rq=1 – flauntster Jan 28 '14 at 06:24
0

I don't probably understand the question correctly. But if you are trying to reorder the actual table in the database then I don't think that's possible with the query you are trying to fire. The query will only sort the result and not the actual table. If you need to sort the actual table, you may need to additional things while insertion. Anyways, I think it is better to get a sorted output using a query than trying to sort the actual array.

suchitra nair
  • 535
  • 7
  • 13