0

This my table

Table View

This what I want

enter image description here

Its gonna be easy if we use php, but I want to know, is it possible with query?

brombeer
  • 8,716
  • 5
  • 21
  • 27
  • 1
    Welcome! Stack Overflow is *not* a code writing service. We are always glad to help and support new coders but you need to help yourself first. You are expected to try to write the code yourself. Please read [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) and [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask). – brombeer Feb 10 '22 at 07:12
  • Is there a relationship between id and code ? Write an English description of your problem – tinazmu Feb 10 '22 at 07:14
  • https://stackoverflow.com/questions/9378613/how-to-define-a-custom-order-by-order-in-mysql – Rakesh Jakhar Feb 10 '22 at 07:18
  • @userMT Yes, There is a relationship between id and code, for example : {id : 1, nama : tes, kode:111} have relationship to {id : 111, nama : tes, kode:0} – Roy Harianja Feb 10 '22 at 07:28
  • @RakeshJakhar we have different case – Roy Harianja Feb 10 '22 at 07:52
  • What have you researched? What have you tried? Where are you stuck? – ADyson Feb 10 '22 at 08:29
  • u need a better DB design. `id` is usually `auto-increment` in most DB design. What you need to do is make a separate table for the `kode` and `SELECT... JOIN` the tables – zimorok Feb 10 '22 at 09:30
  • @zimorok I know that but, I just want know is it possible to do it in just one table? – Roy Harianja Feb 10 '22 at 09:35

1 Answers1

0

Select * from table where kode in (Select group_concat(id) as ids from table where kode=0) Order by kode asc

you can try with this type of query