Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 将联接查询中的字段值用作列_Mysql_One To Many - Fatal编程技术网

Mysql 将联接查询中的字段值用作列

Mysql 将联接查询中的字段值用作列,mysql,one-to-many,Mysql,One To Many,我有两个MySQL表,描述可以扩展为子类的数据,一个描述父类数据,另一个描述元数据字段作为一对多关系 表页面中的示例行: id | name -----+----------------------- 123 | Example page 999 | Another page page_id | key | value --------+------------+---------------- 123 | picture | test.jpg 123

我有两个MySQL表,描述可以扩展为子类的数据,一个描述父类数据,另一个描述元数据字段作为一对多关系

页面中的示例行:

id   | name
-----+-----------------------
123  | Example page
999  | Another page
page_id | key        | value
--------+------------+----------------
123     | picture    | test.jpg
123     | video      | example.avi
123     | sound      | sound.mp3
999     | picture    | something.jpg
页面\u元数据中的示例行:

id   | name
-----+-----------------------
123  | Example page
999  | Another page
page_id | key        | value
--------+------------+----------------
123     | picture    | test.jpg
123     | video      | example.avi
123     | sound      | sound.mp3
999     | picture    | something.jpg
问题:是否有办法以这种格式获取所有这些数据

id   | name             | picture       | video       | sound
-----+------------------+---------------+-------------+------------------
123  | Example page     | test.jpg      | example.avi | sound.mp3
999  | Another page     | something.jpg | NULL        | NULL
试一试

你应该得到你需要的

试试看


你应该得到你需要的

是的,这就足够了。我只将
internal
更改为
LEFT
,以包括没有附加任何元数据的页面。谢谢是的,这就足够了。我只将
internal
更改为
LEFT
,以包括没有附加任何元数据的页面。谢谢