Read Blog

Membuat kode otomatis dengan case when

Membuat kode otomatis dengan case when

SELECT
tblregisbayar.idregbayar AS idregbayar,
tblregisbayar.nama AS nama,
tblregisbayar.jkel AS jkel,
tblregisbayar.alamat AS alamat,
tblregisbayar.email AS email,
tblregisbayar.kodepos AS kodepos,
tblregisbayar.tempatlahir AS tempatlahir,
tblregisbayar.tgllahir AS tgllahir,
tblregisbayar.asalsekolah AS asalsekolah,
tblregisbayar.telp AS telp,
tblregisbayar.agama AS agama,
tblregisbayar.tahunlulus AS tahunlulus,
tblregisbayar.tglinput AS tglinput,
tblregisbayar.capcha AS capcha,
tblregisbayar.ssid AS ssid,
infocalon.idinfo AS idinfo,
infocalon.info AS info,
tblkampus.kodekampus AS kodekampus,
tblkampus.namakampus AS namakampus,
ta.idta AS idta,
`status`.idstatus AS idstatus,
`status`.`status` AS `status`,
(case when (length(`tblregisbayar`.`idregbayar`) = 1) then concat(`tblkampus`.`kodekampus`,’0000′,`tblregisbayar`.`idregbayar`)
when (length(`tblregisbayar`.`idregbayar`) = 2) then concat(`tblkampus`.`kodekampus`,’0000′,`tblregisbayar`.`idregbayar`)
when (length(`tblregisbayar`.`idregbayar`) = 3) then concat(`tblkampus`.`kodekampus`,’000′,`tblregisbayar`.`idregbayar`)
when (length(`tblregisbayar`.`idregbayar`) = 4) then concat(`tblkampus`.`kodekampus`,’00’,`tblregisbayar`.`idregbayar`) when (length(`tblregisbayar`.`idregbayar`) = 5) then concat(`tblkampus`.`kodekampus`,’0′,`tblregisbayar`.`idregbayar`)
when (length(`tblregisbayar`.`idregbayar`) = 6) then concat(`tblkampus`.`kodekampus`,”,`tblregisbayar`.`idregbayar`) end) AS koderegisbayar,
tblkonsentrasi.kodekon AS kodekon,
tblkonsentrasi.namakon AS namakon,
tblkampus.alamatkampus AS alamatkampus,
tblregisbayar.noijazah AS noijazah,
tblregisbayar.idpegawai AS idpegawai
from (((((`tblregisbayar` join `infocalon` on((`infocalon`.`idinfo` = `tblregisbayar`.`idinfo`))) join `tblkampus` on((`tblkampus`.`kodekampus` = `tblregisbayar`.`kodekampus`))) join `ta` on((`tblregisbayar`.`idta` = `ta`.`idta`))) join `status` on((`status`.`idstatus` = `tblregisbayar`.`idstatus`))) join `tblkonsentrasi` on((`tblkonsentrasi`.`kodekon` = `tblregisbayar`.`kodekon`)))



Admin,


Komentar Anda


727


Hubungi Saya

Apakah Anda siap untuk bekerja sama?

Mari kita mulai sebuah Proyek! Hubungi Saya.

Saya sangat senang apabila perusahaan saya dapat bekerja sama dengan bisnis anda. Apabila anda memiliki pertanyaan, silahkan hubungi saya.

//