| 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? | mos | 19 Dec |
| • Re: How to Square a number? | James Harvard | 19 Dec |
| • Re: How to Square a number? | mos | 19 Dec |
| • Re: How to Square a number? | Peter Brawley | 19 Dec |
| • Re: How to Square a number? | mos | 19 Dec |
| • Re: How to Square a number? | Elmar von Muralt | 19 Dec |
| • Re: How to Square a number? | mos | 19 Dec |
| • Re: How to Square a number? | SGreen | 19 Dec |
| • Re: How to Square a number? | Hugh Sasse | 19 Dec |
| • RE: How to Square a number? | SST - Adelaide) | 19 Dec |
| • RE: How to Square a number? | mos | 20 Dec |
| • RE: How to Square a number? | SST - Adelaide) | 20 Dec |
