0
私はuser_idとuser_detailsを持つuserテーブルを持っています。以下に示すような文字列形式でJSONデータを含む:JSONを解析するSQLクエリ
1-
[{"name":"question-1","value":"sachin","label":"Enter your name?"},
{"name":"question-2","value":"[email protected]","label":"Enter your email?"},
{"name":"question-3","value":"xyz","label":"Enter your city?"}]
2-
[{"name":"question-1","value":"sachin123","label":"Enter your name?"},
{"name":"question-2","value":"[email protected]","label":"Enter your email?"},
{"name":"question-3","value":"xyz","label":"Enter your city?"},
{"name":"question-4","value":"red","label":"Enter your favourite color?"}]
3-
[{"name":"question-1","value":"","label":"Enter your name?"},
{"name":"question-3","value":"xyz","label":"Enter your city?"},
{"name":"question-4","value":"red","label":"Enter your favourite color?"}]
4-
[{"name":"question-1","value":"","label":"Enter your name?"},
{"name":"question-2","value":"[email protected]","label":"Enter your email?"},
{"name":"question-3","value":"abc","label":"Enter your city?"},
{"name":"question-4","value":"pink","label":"Enter your favourite color?"}]
予想される出力は次のとおり
row Enter your name? | Enter your email? | Enter your city? | Enter your favourite color?
1 sachin | [email protected] | xyz | -
2 sachin123 | [email protected] | xyz | red
3 - | - | xyz | blue
4 - | [email protected] | abc | pink
私はPHPを介してそれを実行しようとしている、それが配列にJSONに変換し、それを比較することによって可能です。それはMySQLのクエリを使用して直接取得する簡単な方法はありますか?
これについては、[MySQL](https://dev.mysql.com/doc/refman/5.7/en/json-search-functions.html)のドキュメントを見てください。私は 'JSON_EXTRACT'はあなたの探しています。 –
通常の方法でデータを保存するほうがずっと良いでしょう。 – Pete