PostgreSQL FORMAT
From w3cyberlearnings
Contents |
Postgresql format
Format a string. It is similar to sprintf() function in PHP.
Syntax format
- String is a string.
- format is the argument to be inserted in the % sign within string.
format(string, format);
format
- %s is for string
- %% outputs a literal %
- n$ reference to the explicit parameters position, n is the position
- %L escapes its argument as an SQL literal
Example 1
postgres=# SELECT format('Good %s','boy'); format ---------- Good boy (1 row)
Example 2
postgres=# SELECT format('You are %s','smart'); format --------------- You are smart (1 row)
Example 3
postgres=# SELECT format('You are %s',100); format ------------- You are 100 (1 row)