MySQL PHP - three tables - several rows in the thirde. How?
Hi I hope someone can help me with this.
I have got three tables.
doenet_posts contains title and text
doenet_term_relationships contains the category
doenet_postmeta contains telephone, email, website etc. in different rows with an own id which is'meta_ID'
I didnot design the database and cannot change it.
If I want to get only e.g. 'telephone' from doenet_postmeta then I have no problem
but if I want also the others to add I don't know how to seperate the telephone, email,website etc from each other.
Also because of p.ID = m.post_id I get as much results as there are corresponding telephone, email,website etc rows
Below is my MySQL code so far.
Any help is greatly appreciated.
$query = "SELECT p.ID, p.post_title, p.post_status, p.post_type, p.post_content, r.object_id, r.term_taxonomy_id, m.meta_id, m.post_id, m.meta_key, m.meta_value FROM doenet_posts p LEFT JOIN (doenet_term_relationships r, doenet_postmeta m) ON (p.ID = r.object_id AND p.ID = m.post_id) WHERE (m.meta_key='telephone' AND r.term_taxonomy_id = 89 AND p.post_status LIKE 'publish' AND p.post_type LIKE 'doeodse-gids') AND (p.post_title IS NOT NULL AND p.post_title != '') ORDER BY p.post_title ASC";$results = mysql_query($query);
$row_results = mysql_fetch_assoc($results);
