MySQL RADIANS() Function
MySQL RADIANS() Function: Converting Degrees to Radians
The RADIANS() function converts an angle measured in degrees into radians. Behind the scenes, MySQL multiplies the input by PI() / 180 and returns a DOUBLE value.
Because SIN(), COS(), TAN(), and COT() all expect radian inputs, RADIANS() acts as the essential bridge whenever your database stores angles or GPS coordinates in degrees.
Syntax
RADIANS(x)
x: Numeric expression representing an angle in degrees.
Practical Example
Suppose demo_customers stores customer latitude and longitude coordinates in degrees. Before computing trigonometric terms for a spherical distance query from a warehouse at (37.7749, -122.4194), convert those coordinates to radians so SIN() and COS() evaluate accurate geographic angles.
SELECT
customer_id,
city,
latitude,
longitude,
ROUND(RADIANS(latitude), 6) AS lat_rad,
ROUND(RADIANS(longitude), 6) AS lon_rad
FROM demo_customers
WHERE customer_id BETWEEN 10 AND 13;
| customer_id | city | latitude | longitude | lat_rad | lon_rad |
|---|---|---|---|---|---|
| 10 | San Jose | 37.3382 | -121.8863 | 0.651675 | -2.127317 |
| 11 | Portland | 45.5152 | -122.6784 | 0.794390 | -2.141142 |
| 12 | Phoenix | 33.4484 | -112.0740 | 0.583785 | -1.956060 |
| 13 | Unknown | NULL | NULL | NULL | NULL |
Row 10 converts 37.3382 degrees cleanly into 0.651675 radians ready for SIN() and COS(). Row 13 has missing coordinates, so both radian outputs stay NULL.
Common Mistakes & NULL Behavior
- Double-converting radian values: Passing values already measured in radians shrinks them by a factor of
57.2958and corrupts downstream trig math. Name degree columns clearly (such aslat_deg). - Passing degrees straight into SIN() or COS(): Skipping
RADIANS()is the top cause of broken geolocation queries in MySQL.COS(45)returns0.5253instead of0.7071. - NULL inputs: Passing
NULLtoRADIANS(NULL)returnsNULL.
Frequently Asked Questions
What does RADIANS(180) return in MySQL?
RADIANS(180) returns 3.141592653589793, which equals PI().
How do I convert radians back into degrees?
Use DEGREES(rad_val). Together, DEGREES(RADIANS(x)) restores x (subject to normal floating-point rounding).
Does RADIANS() work with negative degree angles?
Yes. Southern latitudes and western longitudes pass through cleanly as negative degrees and become negative radians.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With
Try it Yourself
Experiment with the code from this lesson in our interactive playground.