tabel 1 (user)
uid | nama_lengkap | username | password --------------------------------------------- 1 | Fery W | admin | admin 2 | Minato | minato | minato |
tabel 2 (user_desc)
udid | uid | key | value ------------------------------------------- 1 | 1 | alamat | Pekalongan 2 | 1 | telp | 08756382927 3 | 1 | keterangan | - 4 | 2 | alamat | Konoha Gakure 5 | 2 | telp | 08575648274 6 | 2 | keterangan | - |
TAMPILAN DATA
uid | nama_lengkap | username | password | alamat | telp | keterangan --------------------------------------------------------------------------------------- 1 | Fery W | admin | admin | Pekalongan | 08756382927 | - 2 | Minato | minato | minato | Konoha Gakure | 08575648274 | -
BAHASA QUERYNYA
SELECT nama_lengkap, username, `password`, REPLACE(GROUP_CONCAT(CASE WHEN `key` = "alamat" THEN `value` END, ',') , ',', '') AS alamat , REPLACE(GROUP_CONCAT(CASE WHEN `key` = "telp" THEN `value` END), ',', '') AS telp, REPLACE(GROUP_CONCAT(CASE WHEN `key` = "keterangan" THEN `value` END, ','), ',', '') AS keterangan FROM USER JOIN user_desc ON USER.uid = user_desc.uid GROUP BY user_desc.uid