最好的 mysql 字段设置有一个“夫妇"会员资料保存 [英] best mysql field setup to have a "couples" member profile data saving
问题描述
对数据库配置文件条目,这将是保存数据的最佳方式.此外,数据将通过 php 编码检索,如果可以使用一个理想的查询代码将其关闭.
Couple database profile entry, which would be the best way to save data. Also the data will be retrieved via php coding and if it could be down with one query code that would be ideal.
在 site_member 表中,为每个字段创建多个字段...例如:m_firstname1、m_firstname2、m_age1、m_age2 等...
Within the site_member table create multiple field for each field... ex: m_firstname1, m_firstname2, m_age1, m_age2, etc...
将夫妻成员数据分别存储在一个字段中...并在数据字段中用逗号分隔,例如:m_firstname (Mike, Sherry)
Store the couple member data in one field each... and separate with a comma in the data field ex: m_firstname (Mike, Sherry)
创建一个单独的表 site_member_c,复制 site_member 表中的相同字段.这大约是 10 个字段
Create a separate table site_member_c duplicating the same fields that are in site_member table. This is roughly about 10 fields
推荐答案
为什么不直接添加一个 mate_id
字段来匹配一对?
why not just to add a mate_id
field to match a couple?
你可以使用一个简单的连接:
you could use a simple join then:
SELECT h.*, w.name as w_name ... FROM members h, members w WHERE w.mate_id = h.id
这篇关于最好的 mysql 字段设置有一个“夫妇"会员资料保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!