Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formulas In MySQL

Status
Not open for further replies.

New2Biz

Programmer
Oct 23, 2007
12
US
Within a MYSQL database, is it possible to set up a column as a function (similar to Excel) For example if I have a column titled "sales" and a column titled "Costs" can I set up a column called "Profit" that will automatically subtract "Costs" from "Sales"?
 
Not quite, however you can set up a query that returns that information as a column, however no actual column exists.


for instance:

SELECT column1, column2, (column1-column2) as result FROM mytable.


And it will return 3 columns. the last one having the value of the operation of column1 minus column 2



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top