Conversion

FROM_BASE

DuckDBDuckDB

Mengkonversi string representasi angka dari base tertentu ke integer.

Tipe hasil: BIGINTDiperbarui: 6 Jan 2026

Syntax

SQL
FROM_BASE(string, base)

Parameter

stringVARCHARwajib

String representasi angka

baseINTEGERwajib

Base sumber (2-36)

Contoh Penggunaan

Binary ke Integer

SQL
1SELECT FROM_BASE('11111111', 2) AS decimal;

Binary 11111111 ke decimal.

Hasil
255

Hex ke Integer

SQL
1SELECT FROM_BASE('ff', 16) AS decimal;

Hex ff ke decimal.

Hasil
255

Decode Short Code

SQL
1SELECT FROM_BASE('2s', 36) AS original_id;

Decode base36 short code.

Hasil
100

Parse Color Code

SQL
1SELECT
2 '#FF5733' AS color,
3 FROM_BASE(SUBSTRING('#FF5733', 2, 2), 16) AS red,
4 FROM_BASE(SUBSTRING('#FF5733', 4, 2), 16) AS green,
5 FROM_BASE(SUBSTRING('#FF5733', 6, 2), 16) AS blue;

Parse hex color code.

Hasil
#FF5733 | 255 | 87 | 51