0

i want to SELECT Data from two tables. The output from the second table should be in JSON Format. The "FOR JSON Path" or "FOR JSON AUTO" cause errors (no valid keyword or JSON not known). I think this has to do with my phpmyadmin (test-environment), that the mysql version is to old.

Are there any other solutions?

Example: Table1 (id, col1, col2)

Table2 (id, attr)

Excepted Result: id, col1, col2, "{id: , attr: "", id: , attr: "" }"

My Test:

SELECT id, col1, col2, (SELECT * FROM table2 FOR JSON PATH)
FROM table1 
jarlh
  • 42,561
  • 8
  • 45
  • 63
Navy
  • 5
  • 3
  • Maybe you need: [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) or [docs](https://dev.mysql.com/doc/refman/8.0/en/json-function-reference.html), like [json_insert](https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.html#function_json-insert) – Luuk Apr 08 '22 at 13:21
  • "that the mysql version is to old" Please share the current version, and not "is too old". – Luuk Apr 08 '22 at 13:23
  • 1
    Does this answer your question? [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) – Stoff Apr 08 '22 at 13:23

0 Answers0