MySQL

Fungsi SQL MySQL

Database relasional open-source yang populer. 200 fungsi tersedia.

Menampilkan 24 dari 200 fungsi

SUBSTRING_INDEX

String

Mengambil substring berdasarkan delimiter. Berguna untuk parsing string seperti path, URL, atau CSV.

Tipe hasil: VARCHAR

SUBTIME

Date & Time

Subtracts a time value (expr2) from a datetime or time expression (expr1).

Tipe hasil: TIME/DATETIME

SUM

Aggregate

Menghitung total penjumlahan dari nilai-nilai dalam kolom numerik. Mengabaikan nilai NULL dan dapat menggunakan DISTINCT untuk menjumlahkan nilai unik saja.

Tipe hasil: DOUBLE | DECIMAL

SYSDATE

Date & Time

Mengembalikan waktu saat fungsi dieksekusi. Berbeda dengan NOW() yang konstan per statement.

Tipe hasil: DATETIME

TAN

Math

Menghitung nilai tangen dari sudut dalam radian. TAN(x) = SIN(x) / COS(x).

Tipe hasil: DOUBLE

TIME

Date & Time

Mengekstrak bagian waktu dari datetime atau timestamp. Menghapus komponen tanggal.

Tipe hasil: TIME

TIMEDIFF

Date & Time

Calculates the difference between two time values. Returns a TIME value representing the difference.

Tipe hasil: TIME

TIMESTAMPADD

Date & Time

Adds an interval to a datetime value. Returns the new datetime after the addition.

Tipe hasil: DATETIME

TIMESTAMPDIFF

Date & Time

Calculates the difference between two datetime values in a specified unit. More flexible than DATEDIFF.

Tipe hasil: BIGINT

TIME_FORMAT

Conversion

Formats a TIME value into a string according to the specified format. Similar to DATE_FORMAT but designed specifically for time values.

Tipe hasil: VARCHAR

TIME_TO_SEC

Date & Time

Converts a TIME value to the total number of seconds. The inverse of SEC_TO_TIME().

Tipe hasil: INT

TRIM

String

Menghapus karakter tertentu dari awal dan/atau akhir string. Default menghapus spasi dari kedua sisi.

Tipe hasil: VARCHAR

TRUNCATE

Math

Memotong angka ke jumlah desimal tertentu tanpa pembulatan. Berbeda dengan ROUND.

Tipe hasil: DECIMAL/DOUBLE

UCASE

String

Alias untuk UPPER. Mengubah semua karakter dalam string menjadi huruf kapital. Spesifik MySQL.

Tipe hasil: VARCHAR

UNHEX

String

Mengonversi string hexadecimal kembali ke binary string. Kebalikan dari HEX().

Tipe hasil: VARBINARY

UNIX_TIMESTAMP

Conversion

Returns the Unix timestamp (seconds since 1970-01-01 00:00:00 UTC). When called with no argument, returns the current Unix timestamp.

Tipe hasil: BIGINT

UPPER

String

Mengubah semua karakter dalam string menjadi huruf kapital (uppercase). Alias: UCASE.

Tipe hasil: VARCHAR

USER

Conversion

Returns the username and hostname of the current MySQL connection.

Tipe hasil: VARCHAR

UTC_DATE

Date & Time

Mengembalikan tanggal UTC saat ini. Berguna untuk aplikasi multi-timezone.

Tipe hasil: DATE

UTC_TIME

Date & Time

Mengembalikan waktu UTC saat ini tanpa tanggal. Berguna untuk aplikasi multi-timezone.

Tipe hasil: TIME

UTC_TIMESTAMP

Date & Time

Mengembalikan tanggal dan waktu UTC saat ini. Berguna untuk menyimpan timestamp yang konsisten.

Tipe hasil: DATETIME

UUID

Conversion

Generates a version 1 Universal Unique Identifier (UUID). The returned value follows the format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

Tipe hasil: VARCHAR(36)

UUID_SHORT

Conversion

Generates a unique 64-bit unsigned integer. Faster and more compact than UUID().

Tipe hasil: BIGINT UNSIGNED

UUID_TO_BIN

Conversion

Converts a UUID string to BINARY(16) format for more efficient storage.

Tipe hasil: BINARY(16)