Skip to main content

PRINTF

Description

Returns a formatted string using the specified printf string and arguments.

tip

This function is supported since version 3.0.6.

Syntax

PRINTF(<format>, [<args>, ...])

Parameters

ParameterDescription
<format>The printf format string.
<args>The arguments to be formatted.

Return Value

The formatted string using a printf mode.

Example

select printf("hello world");
+-----------------------+
| printf("hello world") |
+-----------------------+
| hello world |
+-----------------------+
select printf('%d-%s-%.2f', 100, 'test', 3.14);
+-----------------------------------------+
| printf('%d-%s-%.2f', 100, 'test', 3.14) |
+-----------------------------------------+
| 100-test-3.14 |
+-----------------------------------------+
select printf('Int: %d, Str: %s, Float: %.2f, Hex: %x', 255, 'test', 3.14159, 255);
+-----------------------------------------------------------------------------+
| printf('Int: %d, Str: %s, Float: %.2f, Hex: %x', 255, 'test', 3.14159, 255) |
+-----------------------------------------------------------------------------+
| Int: 255, Str: test, Float: 3.14, Hex: ff |
+-----------------------------------------------------------------------------+