| id | nama_user | kode_cabang | kode_wilayah | kode_jalan |
|---|---|---|---|---|
| 1 | jon | 01 | 03 | 01 |
| 2 | jin | 01 | 03 | 01 |
| 3 | jun | 01 | 03 | 04 |
| 4 | siz | 01 | 03 | 02 |
| 5 | suz | 01 | 03 | 03 |
I have a database like above. I want to return jon,jin,siz,suz values in nama_user field.
How can I select from mytable where kode_cabang=01 and kode_wilayah=03 and kode_jalan = 01,02,03
You can use GROUP_CONCAT to get values in one columns
like below
select GROUP_CONCAT(nama_user) as nama_user from table_name
where kode_cabang = 01 and kode_wilayah = 03 and kode_jalan IN (01,02,03)
it will return single row concat name by comma.
Use IN
select nama_user from table_name where kode_cabang = 01 and kode_wilayah = 03
and kode_jalan IN (01,02,03)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With