Jump to content

Recommended Posts

I'm quite confused as if this is even possible. I'm pretty novice when it comes to MySQL and I was trying something like this earlier. I have no idea how to go about it. I suppose an example may be in order..

 

I have ten people in a database, these ten people have a bank account and a wallet. I would like to order these ten people by the total of their bank account and wallet. Is that possible with just an SQL query or will I have to write some sort of PHP array sorting system?

 

Sorry if this is the wrong forum, the only other forum that it looked like it belonged in was PHP Newbies but since this is an SQL question I thought it probably belongs here. Also sorry if this is explained somewhere I didn't really know what to look for, like I said, novice. Any help is appriciated.

Link to comment
https://forums.phpfreaks.com/topic/3025-order-by-the-total-of-two-entries/
Share on other sites

[!--quoteo(post=326727:date=Dec 12 2005, 10:33 AM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ Dec 12 2005, 10:33 AM) 326727[/snapback][/div][div class=\'quotemain\'][!--quotec--]

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] *, bank+wallet AS totalAmt FROM users ORDER BY totalAmt [!--sql2--][/div][!--sql3--]

 

Thank you so much, ryanlwh. You're a life saver. I wish I could hug you. :D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.