String
PostgreSQL
INITCAP
Mengubah huruf pertama setiap kata menjadi kapital (Title Case). Kata dipisahkan oleh karakter non-alphanumeric.
Tipe hasil:
textSyntax
SQL
INITCAP(string)Parameter
stringtextwajib
String yang akan dikonversi ke Title Case
Contoh Penggunaan
Title Case Dasar
SQL
1 SELECT INITCAP(hello world);
Mengubah ke Title Case.
Hasil
| initcap |
|---|
| Hello World |
Format Nama
SQL
1 SELECT 2 INITCAP(first_name) || || INITCAP(last_name) AS formatted_name 3 FROM users 4 WHERE first_name = LOWER(first_name);
Memformat nama yang tersimpan dalam lowercase.
Hasil
| formatted_name |
|---|
| John Doe |
| Jane Smith |
Handle Mixed Input
SQL
1 SELECT 2 INITCAP(jOHN DOE) AS from_mixed, 3 INITCAP(JOHN DOE) AS from_upper, 4 INITCAP(john-doe) AS with_hyphen;
INITCAP menormalkan case apapun input-nya.
Hasil
| from_mixed | from_upper | with_hyphen |
|---|---|---|
| John Doe | John Doe | John-Doe |