FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Calculations in mysql





MWANGI
Hello everyone

I am expected to create reports and invoices that will work online by my boss but I am poor in sql (views and calculations)so I was wondering how and where to code totals of fields, differences and averages.Please Help.Anyone.Thanks(My job may be at risk)
It would be very helpful if I can get some sample code and instructions on where to paste it and how to access the result of these calculations.Thanks again in advance.
poppitz
Hi,

you can calculate very easy with sql.
eg
select sum(price)
from table
where ...

deliveres price1 + price2 + price3 + ...

you can do the same with avg(price) to get the average or calculate directly:

select column1 - column2
from table

or what you need.

you can create php pages to execute your queries or you install mysql control center on your boss' pc and give him the queries or you maybe you can use phpMyAdmin so you can access the database via webbrowser.
MWANGI
Thanks alot.It's easier than I thought.What about minus and date difference?Is it also as easy
poppitz
Yes, you can use minus also for dates.
eg you can say curdate() -1 for yesterday or

select *
from table
where date_column > curdate() -1

for all records from today
jabapyth
cool Cool
i diddnt know that. Thanks!
gstreams
you can also calculate in months, years, hours, etc.

SELECT NOW()+INTERVAL 1 MONTH;
It does help you overcome calculating the number of days in the current month or so ... i found it very usefull.
Related topics
mysql connection question
php admin and mysql admin console
Mysql And PHP HELP PLZ
Do you use a CMS script?
Question about MySQL!
PHP, MySQL...
PHP Book (Php and Mysql for Dynamic Web Sites)
few mysql questions
E-Cards with PHP & MySQL
HTTP AUTH with PHP and mySQL
Build an online dictionary by PHP/MySQL
Make search engine With PHP and mySQL, for your site
PHP without mySQL
Multiple versions of PHP/MySQL
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.