0% found this document useful (0 votes)
2 views4 pages

MySQL Functions & Operators Guide

The document provides an overview of MySQL functions and operators, categorized into sections such as pattern matching, mathematical functions, trigonometric functions, and bitwise operations. Each section includes descriptions and examples in Hinglish for better understanding. It emphasizes the importance of practicing commonly used functions for better retention and preparation for interviews.

Uploaded by

valiyiw441
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

MySQL Functions & Operators Guide

The document provides an overview of MySQL functions and operators, categorized into sections such as pattern matching, mathematical functions, trigonometric functions, and bitwise operations. Each section includes descriptions and examples in Hinglish for better understanding. It emphasizes the importance of practicing commonly used functions for better retention and preparation for interviews.

Uploaded by

valiyiw441
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

📘 MySQL Functions & Operators – With Examples (Section-wise)

🔹 1. Pattern Matching & Comparison Operators

Description
Operator Example
(Hinglish)

REGEXP / Pattern match SELECT * FROM student WHERE name REGEXP


RLIKE using regex '^A'; → A se start hone wale naam.

Pattern match SELECT * FROM employee WHERE name LIKE


LIKE
with %, _ 'R%'; → R se start hone wale naam.

Check value in SELECT * FROM product WHERE category IN


IN
list ('Electronics', 'Clothing');

Value within SELECT * FROM orders WHERE price BETWEEN


BETWEEN
range 100 AND 500;

SELECT * FROM student WHERE address IS


IS NULL Check for null
NULL;

=, !=, >, < Comparison SELECT * FROM users WHERE age > 18;

SELECT * FROM users WHERE NOT city =


NOT Negation
'Delhi';

Combine SELECT * FROM login WHERE status = 'active'


AND / OR
conditions AND role = 'admin';

🔹 2. Basic Mathematical Functions

Description
Function Example
(Hinglish)

ABS(x) Absolute value SELECT ABS(-15); → 15

CEIL(x) Round up SELECT CEIL(4.2); → 5

FLOOR(x) Round down SELECT FLOOR(4.8); → 4

ROUND(x) Nearest integer SELECT ROUND(4.5); → 5


ROUND(x, d) Round to decimals SELECT ROUND(4.567, 2); → 4.57

TRUNCATE(x, SELECT TRUNCATE(4.567, 2); →


Cut decimals
d) 4.56

SQRT(x) Square root SELECT SQRT(25); → 5

POWER(x, y) Power SELECT POWER(2, 3); → 8

MOD(x, y) Modulus SELECT MOD(10, 3); → 1

SIGN(x) Number sign SELECT SIGN(-50); → -1

EXP(x) e^x SELECT EXP(1); → 2.718...

LOG(x) Natural log SELECT LOG(2.71828); → 1

LOG10(x) Log base 10 SELECT LOG10(1000); → 3

LOG2(x) Log base 2 SELECT LOG2(8); → 3

PI() Returns π SELECT PI(); → 3.14159...

SELECT RAND(); → 0.7123


RAND() Random decimal
(random)

SELECT MAX(salary) FROM


MAX(col) Max from column
employees;

SELECT MIN(salary) FROM


MIN(col) Min from column
employees;

LEAST(x, y, …) Smallest SELECT LEAST(5, 8, 2, 9); → 2

GREATEST(x, y, SELECT GREATEST(5, 8, 2, 9); →


Largest
…) 9

🔹 3. Trigonometric & Angle Functions

Description
Function Example
(Hinglish)

SELECT SIN(RADIANS(30)); →
SIN(x) Sine of angle
0.5

COS(x) Cosine SELECT COS(RADIANS(60)); →


0.5

TAN(x) Tangent SELECT TAN(RADIANS(45)); → 1

SELECT DEGREES(ASIN(0.5));
ASIN(x) Inverse sine
→ 30

SELECT DEGREES(ACOS(0.5));
ACOS(x) Inverse cosine
→ 60

SELECT DEGREES(ATAN(1)); →
ATAN(x) Inverse tangent
45

ATAN2(y, SELECT DEGREES(ATAN2(2,


Angle from x-y
x) 2)); → 45

SELECT COT(RADIANS(45)); →
COT(x) Cotangent
1

DEGREES(
Radian to degree SELECT DEGREES(PI()); → 180
x)

RADIANS( SELECT RADIANS(180); →


Degree to radian
x) 3.14159...

🔹 4. Bitwise & Base Conversion Functions

Description
Function Example
(Hinglish)

BIT_COUNT( SELECT BIT_COUNT(7); → 3


Count 1s in binary
x) (binary: 111)

BIN(x) Binary string SELECT BIN(10); → '1010'

Hexadecimal
HEX(x) SELECT HEX(255); → 'FF'
string

OCT(x) Octal string SELECT OCT(64); → '100'

CONV(x, f,
Convert base SELECT CONV('A', 16, 10); → 10
t)

✅ Revision Tip:
Jo functions tum bar-bar real queries me use karoge wo yaad automatically
ho jaate hain — lekin unusual (like trigonometric ya binary) functions ko
revise karte raho for viva/interview.

You might also like