Mysql Many to Many Select with PHP -
i have search dont solve problems. have many many relationship.
3 tables:
groups_mail | groups_mail_j (joint table) | mails id, name | mail_id, groupe_id | id, name i dont know how select emails groupe id=1
thx.
your question not clear. anyways have understood based on question.
your having 3 tables mails, groups_mail, groups_mail_j
you want join tables , records based on mails-> id column.
if above required on can following
select m.id mailid, m.name email, gm.name groupname, gm.id groupmailid mails m inner join groups_mail_j gmj on gmj.mail_id = m.id inner join groups_mail gm on gm.id = gmj.groupe_id m.id = 1 here have used custom selectors. can use selector ie specific column of tables using alias of table.
okay in-case want show mail-ids selected group use following query. no need put mail_id because if knew mail id wouldn't have query again.
select m.name email mails m inner join groups_mail_j gmj on gmj.mail_id = m.id inner join groups_mail gm on gm.id = gmj.groupe_id gmj.groupe_id = 1 here 1 in hard coded in case can user $group_id
please check spelling whether group_id or groupe_id
Comments
Post a Comment