Click here to Skip to main content
15,914,500 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How should i insert a new in mysql after existing one.
First row i have entered as
name mobno.
ABC 123
now i have to insert again one row in mysql
name mobno
xyz 346
mysql table shows the result as

name mobno.
xyz 346
ABC 123

but I want result in the following format

name mobno.
ABC 123
xyz 346
Please help me it will solve my big problem..
Posted
Comments
Sandeep Mewara 12-Jul-12 3:07am    
Are you saying that the order is opposite of what you are expecting? Record inserted first should be at the top, right?
If so, As per me, by default it should be like that!
project virus 12-Jul-12 3:11am    
yes you are right
project virus 12-Jul-12 3:13am    
but i want to change that default setting.I mean that id should be display in asceding order.by default it is in descending order

You would simply need to order it the correct way. A solution would be to simply order it by converting it all to lowercase first.
SQL
SELECT name, mobno FROM tb_users ORDER BY LOWER(name) ASC


Good luck!
 
Share this answer
 
Comments
project virus 12-Jul-12 3:25am    
I dont want to select it i want to store that data in that format
E.F. Nijboer 12-Jul-12 6:53am    
How do you mean? You want the result in that format. The result is produced by a query. There is no control over how a database engine stores it internally. You need to specify it when retrieving it or live with the order the database gives you back.
project virus 12-Jul-12 7:57am    
Yes I know that ... But Your query does not useful to me.
Because I just want above format by inserting a row in database table not for selection of rows??
Cal I insert that rows after selecting it in a new table?? Can I use ORDER BY MIN(id) instead of using ORDER BY LOWER(name)
E.F. Nijboer 12-Jul-12 8:07am    
ORDER BY MIN(id) won't work, just try ORDER BY id
project virus 12-Jul-12 8:13am    
but it will show the data in descending order:
like: 1
2
3
4
I want my data as
id : 4
3
2
1
By doing setting in operation in descending order to the 'id'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900