Sorting table with query

I want to sort this table, order by RESULT. but, the result of RESULT doesn't stored in database. What can i do? Thanks for your help.

data "Title & 1st number" is stored on table "table1".

data "2nd number" is stored on table "table2", but i just want to take one number.

data "result" does'nt stored on any table.

Title | 1st number | 2nd number | substraction | result

A | 80 | 65 | 80 - 65 | 15

B | 78 | 43 | 78 - 65 | 35

C | 100 | 95 | 100 - 65 | 5

I want to sort it by result. What should I use (query)? Thanks for your help.


Try this query

SELECT tbl1.title,tbl1.num1,tbl2.num2, CONCAT(tbl1.num1 , "-", tbl2.num2),(tbl1.num1 - tbl2.num2) as result 
FROM tbl1,tbl2 
ORDER BY result

below is your correct solution to sorting in result column

SELECT (tbl1.num1 - tbl2.num2) as result, from  
                table1 as tbl1,table1  as tbl2 
                    where  ORDER BY result Desc

let me know if i can help you more..

Need Your Help

Can I dynamically select fields in a database using parameterised SQL?

php mysql database sqlbindparameter

I have a database table, USER_OPTIONS, containing a field for each of a variety of options in an application, it looks effectively as follows:

Why must a method be declared in a C++ class definition?

c++ declaration

If only define this method it will have a compiler error.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.