Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

MySQL String Functions

MySQL String Functions

Function

Description

ASCII

You could rephrase it as “Provides the ASCII value corresponding to a specific character.”

CHAR LENGTH

You could say, “Gives the count of characters in a string.”

LENGTH

Sure, here’s a rephrased version: “Determines the number of characters in a string.”

CONCAT

You could say, “Combines two or more expressions.”

CONCAT WS

Here’s a rephrased version: “Combines two or more expressions using a specified separator.”

FIELD

You might say, “Provides the position of a value within a list of values.”

FIND IN SET

“Provides the index of a string within a list of strings.”

FORMAT

“Formats a number to a specified decimal place and applies a pattern like “#,###,###.##”.”

INSERT

“Places a string within another string at a specified position, replacing a certain number of characters.”

INSTR

“Provides the index of the first occurrence of a string within another string.”

LCASE

“Changes a string to lowercase.”

LEFT

“Retrieves a specified number of characters from the left side of a string.”

LENGTH

“Provides the size of a string in bytes.”

LOCATE

“Provides the index of the first occurrence of a substring within a string.”

LOWER

“Changes a string to lowercase letters.”

LPAD

“Pads the left side of a string with another string to reach a specified length.”

LTRIM

“Trims leading spaces from a string.”

MID

“Retrieves a substring from a string, starting at any specified position.”

POSITION

“Provides the index of the initial appearance of a substring within a string.”

REPEAT

“Duplicates a string according to a specified number of repetitions.”

REPLACE

“Substitutes all instances of a substring within a string with a new substring.”

REVERSE

“Returns the reversed form of a string.”

RIGHT

“Retrieves a specified number of characters from the right side of a string.”

RPAD

Appends another string to the right of a string until it reaches a specified length

RTRIM

“Eliminates any whitespace characters at the end of a string.”

SPACE

“Generates a string containing a specified number of space characters.”

STRCMP

Assesses the equality of two strings.”

SUBSTR

“Obtains a portion of a string beginning at any given position.”

SUBSTRING

“Obtains a portion of a string, beginning from any specified position.”

SUBSTRING INDEX

Provides a portion of a string occurring before a specified count of delimiters.

TRIM

“Trims both leading and trailing spaces from a string.”

UCASE

“Changes a string to uppercase letters.”

UPPER

“Changes a string to uppercase.”

MySQL Numeric Functions

Function

Description

ABS

Provides the absolute value of a number

ACOS

Provides the arc cosine of a number

ASIN

provides the angle, measured in radians, whose sine is the given number.

ATAN

provides the angle, measured in radians, whose tangent is the given number or the ratio of two given numbers.

ATAN2

provides the angle, measured in radians, whose tangent is the quotient of the two given numbers

AVG

provides the mean value of an expression.

CEIL

provides the smallest integer value that is equal to or greater than a given number.

CEILING

provides the minimum integer value that is greater than or equal to a given number.

COS

provides the ratio of the length of the adjacent side to the length of the hypotenuse in a right triangle, given the angle (in radians).

COT

provides the ratio of the adjacent side length to the opposite side length in a right triangle, given the angle (in radians).

COUNT

provides the count of records retrieved by a select query.

DEGREES

transforms a value given in radians into its equivalent measurement in degrees.

DIV

Utilized for integer division

EXP

provides the value of Euler’s number raised to the power of a specified exponent.

FLOOR

provides the maximum integer value that is less than or equal to a given number.

GREATEST

provides the highest value among the list of arguments.

LEAST

provides the minimum value among the list of arguments.

LN

Returns the natural logarithm of a number

LOG

Calculates the logarithm of a specified number, either to the natural base or to a base chosen by the user.

LOG10

Rewrite the sentence to express the concept differently.

LOG2

It calculates the logarithm of a number using base 2.

MAX

Provides the highest value among a group of values.

MIN

Provides the smallest value within a set of values.

MOD

Provides the leftover amount when one number is divided by another.

PI

Provides the value of PI

POW

Provides the result of raising a number to the power of another number.

POWER

Provides the result of multiplying a number by itself a certain number of times.

RADIANS

Converts a degree measurement into radians.

RAND

Produces a randomly generated number.

ROUND

Adjusts a number to a certain precision by rounding it to a specified number of decimal places.

SIGN

Provides the indication of whether a number is positive, negative, or zero.

SIN

Produces the trigonometric sine value of a given number.

SQRT

Provides the mathematical operation of finding the square root of a given number.

SUM

Determines the total value obtained by adding together a group of values.

TAN

Produces the trigonometric tangent value of a given number.

TRUNCATE

Adjusts a number to a specific precision by removing digits after the decimal point beyond a specified number of decimal places.

MySQL Date Functions

Function

Description

ADDDATE

Add a specified time or date interval to it, then returns the resulting date.

ADDTIME

Add the new time/datetime by adding the interval to the initial time/datetime.

CURDATE

Retrieve the current date

CURRENT DATE

Retrieve the current date

CURRENT TIME

Retrieve the current time.

CURRENT TIMESTAMP

Retrieve the current date and time.

CURTIME

Retrieve the current time.

DATE

Isolate the date component from this datetime expression.

DATEDIFF

Determine the number of days spanning between two date values

DATE ADD

Add a specified time or date interval to a given date and return the updated date

DATE FORMATE

Formatting a date

DATE SUB

Deduct a specified time or date interval from a given date and then provide the resulting date.

DAY

Provide the numerical day of the month for a specific date.

DAYNAME

Provide the name of the weekday for a given date.

DAYOFMONTH

Retrieve the day of the month for a particular date.

DAYOFWEEK

Retrieve the index of the weekday for a specified date.

DAYOFYEAR

Provide the numerical day of the year for a given date.

EXTRACT

Extract a specific component from a given date.

FROM DAYS

Provide a date corresponding to a numeric date value.

HOUR

Extract the hour component from a given date.

LAST DAY

Extract the final day of the month from a given date.

LOCALTIME

Retrieve the current date and time.

LOCALTIMESTAMP

Retrieve the current date and time.

MAKEDATE

Generate and return a date using a given year and a specified number of days.

MAKETIME

Generate and return a time using specified values for hour, minute, and second.

MICROSECOND

Extract the microsecond component from a given time or datetime.

MINUTE

Extract the minute component from a given time or datetime.

MONTH

Retrieve the month component from a provided date.

MONTHNAME

Provide the name of the month for a given date.

NOW

Provide the current date and time.

PERIOD ADD

Add a designated number of months to a given period.

PERIOD DIFF

Return the duration between two time intervals.

QUARTER

Determine the quarter of the year for a given date.

SECOND

Extract the seconds component from a given time or datetime.

SEC TO TIME

Return a time based on a given number of seconds.

SEC TO DATE

Retrieve a date based on a string and a format

SUBDATE

Subtracts a duration of time or date from a given date and then provides the resulting date.

SUBTIME

Subtracts a specified time duration from a given date and time, then returns the resulting date and time.

SYSDATE

Provide the present date and time.

TIME

Extract only the time component from a provided date or datetime.

TIME FORMATE

format a time according to a specific format.

TIME TO SEC

Convert a time value into seconds.

TIMEDIFF

Retrieve the difference between two time or datetime expressions.

TIMESTAMP

Return a datetime value derived from a given date or datetime value.

TO DAYS

find the number of days between a given date and the date “0000-00-00”.

WEEK

determine the week number corresponding to a given date.

WEEKDAY

determine the weekday number associated with a given date.

WEEKOFYEAR

Retrieve the week number that corresponds to a given date.

YEAR

extract the year part from a given date.

YEARWEEK

Return both the year and the week number for a given date.

MySQL Advanced Functions

Function

Description

BIN

Provide a binary representation of a given number in a different way.

BINARY

Transforms a value into its binary string equivalent.

CASE

Iterates through conditions and returns a value once the initial condition is met.

CAST

Transforms a value, regardless of its type, into a specified data type.

COALESCE

Delivers the initial non-null value found within a list.

CONNECTION ID

Provides the unique connection ID associated with the current connection.

CONV

Translates a number from one numeric base system into another.

CONVERT

Transforms a value into the specified data type or character set.

CURRENT USER

Provides the user name and host name associated with the MySQL account that the server utilized to authenticate the present client.

DATABASE

Delivers the name of the current database in use.

IF

Provides a value based on whether a condition is TRUE or FALSE; alternatively, delivers a different value depending on the condition’s outcome.

IFNULL

Delivers a designated value if the expression is NULL; otherwise, returns the expression itself.

ISNULL

Delivers either 1 or 0 depending on whether an expression is NULL.

LAST INSERT ID

Provides the AUTO_INCREMENT id of the most recent row inserted into a table.

NULLIF

Compares two expressions; if they are equal, NULL is returned. Otherwise, the first expression is delivered.

SESSION USER

Delivers the current MySQL user name and host name.

SYSTEM USER

Provides the MySQL user name and host name currently in use.

USER

Delivers the MySQL user name and host name presently active.

VERSION

Delivers the current version of the MySQL database.