我有 2 张桌子
cbmsH
hh_id | name | age
9437556 | John | 40
9886016 | Doe | 35
建立信任关系
hh_id | name | age
9437556 | Peter | 41
9886016 | Tony | 35
9886016 | Thor | 32
9886016 | Loki | 30
我期待这样
hh_id | name | age
9437556 | John | 40
9437556 | Peter | 41
____________________________
hh_id | name | age
9886016 | Doe | 35
9886016 | Tony | 35
9886016 | Thor | 32
9886016 | Loki | 30
____________________________
我试过这个
SELECT cbmsh.hh_id AS head_hhid, cbmsh.barangay AS head_barangay, cbmsh.memno AS head_memno,cbmsh.last_name AS head_last ,cbmsh.first_name AS head_first ,cbmsh.mid_name AS head_mid,cbmsh.relationship,cbmsh.sex AS head_sex,cbmsh.birthdate AS head_birthdate,cbmsh.age AS head_age,cbmsh.occupation AS head_occupation,cbmsh.pwd_ind, cbms.hh_id AS mem_hhid, cbms.barangay, cbms.memno,cbms.last_name AS mem_last,cbms.first_name AS mem_first,cbms.mid_name AS mem_mid,cbms.relationship AS mem_relationship,cbms.sex AS mem_sex,cbms.birthdate AS mem_birthdate,cbms.age AS mem_age,cbms.occupation AS mem_occupation,cbms.pwd_ind
FROM cbmsh, cbms
WHERE cbmsh.hh_id = cbms.hh_id
GROUP BY head_hhid
但它只显示 1 个这样的数据。而不是显示具有相同 hh_id 的所有记录
hh_id | name | age
9886016 | Doe | 35
9886016 | Tony | 35
有人可以帮我吗?任何帮助将不胜感激!今天是个好日子