update help?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
adilmarwat2004
Forum Commoner
Posts: 44
Joined: Fri Sep 04, 2009 11:28 pm

update help?

Post by adilmarwat2004 »

I have table in mysql name "act" contains 4 fields

id, name, marks, avg(float)

I give the query to sql as

UPDATE act SET avg = marks/550 *100

I want that the result (avg) in field should be 2 decimal point not more.
like 72.63 not 72.6333

How it is possible.

Please Help.
iamngk
Forum Commoner
Posts: 50
Joined: Mon Jun 29, 2009 2:20 am

Re: update help?

Post by iamngk »

can try like this:

Code: Select all

UPDATE act SET avg = round(marks/550 *100,2);
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: update help?

Post by AbraCadaver »

iamngk wrote:can try like this:

Code: Select all

UPDATE act SET avg = round(marks/550 *100,2);
Set the field type in the database to correctly store your number.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply