我正在尝试使用此 JSON 数据编写一个高效的 mySQL INSERT 查询(为清楚起见,转换为 JSON):
[
{
"job": "Avocado Books Binding",
"tasks": [
"Finish collating the signatures",
"Fix perfect binders",
"Fold signatures"
]
},
{
"job": "Prepress Workflow Development",
"tasks": [
"Research new proofing machines",
"Find free proofing software"
]
}
]
生成的表结构将是(使用此数据)
Table: Jobs
job_id job_title
1 Avocado Books Binding
2 Prepress Workflow Development
Table: Tasks
task_id task_description job_id
1 Finish collating the signatures 1
2 Fix perfect binders 1
3 Fold signatures 1
4 Research new proofing machines 2
5 Find free proofing software 2
作业和任务通过 job_id 关联的位置。
我也在尝试编写一个 SELECT 查询,以一种高效的方式获取这些数据。
非常感谢任何帮助、参考或建议。
更新:
结构为 PHP 数组
Array
(
[0] => Array
(
[job] => Avocado Books Binding
[tasks] => Array
(
[0] => Finish collating the signatures
[1] => Fix perfect binders
[2] => Fold signatures
)
)
[1] => Array
(
[job] => Avocado Books Binding
[tasks] => Array
(
[0] => Finish collating the signatures
[1] => Fix perfect binders
[2] => Fold signatures
)
)
)