如何在mysql中连接字段表格

Hi i have table name data and field is:

  • id
  • kode
  • prov_nama
  • kota_nama
  • bus
  • kode_d (field concat)

i use PHPMaker and my followed code is CONCAT (upper(substr(kota_nama,1,2)),kode) example :

  • id: 1
  • kode: 001
  • prov_nama: Jakarta
  • kota_nama: Cijantung
  • Bus:VIP

The output kode_d is : CI001

How to make output kode_d like : JCI001
with concat

Concatenated string = [First character of prov_nama][First two characters of kota_nama][kode]

thanks

Just add the first character of prov_nama

CONCAT(part1, part2, part3, ..., partn)

upper(string) --> To capital case

substr(string, start_index, number_of_characters)

CONCAT(upper(substr(prov_nama,1,1)),upper(substr(kota_nama,1,2)),kode)