0

I have a MySQL table named category. It has a field named id, parent and name like this http://sqlfiddle.com/#!9/15b7ee/1 sql schema

and convert to json like this json

can I get this json only with mysql, or must with PHP to create array and encode_json? any sample for this?

ian
  • 13
  • 2
  • Please have a look on these links [MySQL: Return JSON from a standard SQL Query](https://dba.stackexchange.com/questions/192208/mysql-return-json-from-a-standard-sql-query) and [How to convert result table to JSON array in MySQL](https://stackoverflow.com/questions/41758870/how-to-convert-result-table-to-json-array-in-mysql) – Umer Abbas Mar 29 '20 at 03:55
  • Also this will be helpful: https://stackoverflow.com/questions/20215744/how-to-create-a-mysql-hierarchical-recursive-query – Nick Mar 29 '20 at 04:27
  • I will suggest do it using PHP after getting the result from MySQL. – unclexo Mar 29 '20 at 04:58

0 Answers0