PI() provides MySQL’s approximation of π for calculations involving angles, circles and trigonometric functions.
Run this SELECT query directly in MySQL or phpMyAdmin. It uses fixed inputs so you can verify the result without creating a table.
SELECT ROUND(PI(), 4) AS pi_value;| pi_value |
|---|
| 3.1416 |
SELECT PI();
Output is 3.141593SELECT DEGREES(PI()); -- 180
SELECT DEGREES(PI() / 2); -- 90
SELECT DEGREES(PI() / 3); -- about 60
SELECT SIN(PI()); -- approximately 0 (floating-point)
We can use use ROUND Function to rounds to output
SELECT ROUND(SIN(PI())); -- 0
SELECT ROUND(SIN(PI() / 2)); -- 1
We will allow some decimal places to be shown as the value of SIN varies between 0 and 1.
SELECT ROUND(SIN(PI() / 3), 3); -- 0.866
SELECT ROUND(SIN(PI() / 4), 4); -- 0.7071
We can try COS values
SELECT ROUND(COS(PI() / 3), 3); -- 0.500
SELECT ROUND(COS(PI() / 2), 3); -- 0.000
Trigonometric functions use radians; PI() represents 180 degrees when converted with DEGREES().
Does PI() require any arguments?
No. Call the function as PI().
More related tutorials: All math functions, COS()
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.