MySQL: how to convert to EAV?

六眼飞鱼酱① 提交于 2019-12-01 08:03:45

I'm assuming two.id is an autoincrementing integer, so I'll leave it to the target table to assign those values.

select id as fk_id, 'first_name' as attribute, first_name as value
from one
union all
select id as fk_id, 'last_name', last_name
from one
order by fk_id, attribute

For the love of god, don't use EAV!!!! If you need that, use a NoSQL database instead!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!