Mysql——如何检索NVP值并将其分组?
假设我们有这个MySQL表Mysql——如何检索NVP值并将其分组?,mysql,nvp,Mysql,Nvp,假设我们有这个MySQL表 name value author Sabriel Armstrong author Peter Abhorsen author Garth Stein item bell item book item sword item wand 给定这些数据库条目,是否有方法检索这些值以获得以下格式的值?还是我的数据库建模错误 array( [author] => array(Sa
name value
author Sabriel Armstrong
author Peter Abhorsen
author Garth Stein
item bell
item book
item sword
item wand
给定这些数据库条目,是否有方法检索这些值以获得以下格式的值?还是我的数据库建模错误
array(
[author] => array(Sabriel Armstrong,Peter Abhorsen, Garth Stein),
[item] => array(bell,book,sword, wand)
)
MySQL没有数组,因此很难确定您期望的确切结果集。在任何情况下,DB设计都无法将作者与项目匹配:这样的信息根本不存储在任何地方 我想你有理由避免这样做:
author item
====== ======
Sabriel Armstrong bell
Peter Abhorsen book
:-?我不能将其设置为列的原因是字段名称和值是任意的,可以更改。