List:General Discussion« Previous MessageNext Message »
From:Hugh Sasse Date:December 19 2005 12:18pm
Subject:Re: How to Square a number?
View as plain text  
On Sun, 18 Dec 2005, mos wrote:

> How do I square a number in MySQL 4.1? I thought it would be something simple
> like:
> 
> select 3**2
> 
> but that produces a syntax error. I can use Pow(3,2) but that produces a
> float. Is there a Square function? TIA

mysql> select floor(pow(3,2));
+-----------------+
| floor(pow(3,2)) |
+-----------------+
|               9 |
+-----------------+
1 row in set (0.00 sec)

You might also need round instead of floor depending on whether
the result of pow falls on the low side of the correct result.

> 
> Mike

I'm disappointed by the responses that failed to recognise this as
the simplest specification for a more complicated case.

        Hugh
Thread
How to Square a number?mos19 Dec
  • Re: How to Square a number?James Harvard19 Dec
    • Re: How to Square a number?mos19 Dec
      • Re: How to Square a number?Peter Brawley19 Dec
        • Re: How to Square a number?mos19 Dec
          • Re: How to Square a number?Elmar von Muralt19 Dec
            • Re: How to Square a number?mos19 Dec
  • Re: How to Square a number?SGreen19 Dec
  • Re: How to Square a number?Hugh Sasse19 Dec
RE: How to Square a number?SST - Adelaide)19 Dec
  • RE: How to Square a number?mos20 Dec
RE: How to Square a number?SST - Adelaide)20 Dec