Lesson

MySQL RADIANS() Function

10 min reading
Free Course

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.2958 and corrupts downstream trig math. Name degree columns clearly (such as lat_deg).
  • Passing degrees straight into SIN() or COS(): Skipping RADIANS() is the top cause of broken geolocation queries in MySQL. COS(45) returns 0.5253 instead of 0.7071.
  • NULL inputs: Passing NULL to RADIANS(NULL) returns NULL.

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.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Try it Yourself

Experiment with the code from this lesson in our interactive playground.

Open Playground
MySQL Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum