Daniel_Hatcher Posted May 22, 2007 Share Posted May 22, 2007 This is the code i have. $select_types = db_query("SELECT tid FROM {term_data} WHERE vid=$id"); while ($term = db_fetch_object($select_types)) { $select_types2 = db_query("SELECT b.title, b.nid FROM {term_node} n INNER JOIN {node} b on n.nid=b.nid WHERE n.tid=$term->tid AND b.status=1"); if (mysql_num_rows($select_types2)==0) return 'No tutorials found for this category.'; while ($term2 = db_fetch_object($select_types2)) { $result = db_query("SELECT nid, description FROM {tutorial} WHERE nid='$term2->nid' AND parent=0"); $term3 = db_fetch_object($result); Now i wan't to join all 3 together with JOINS only i can't get it to work it shows the rows about 30 time. Quote Link to comment https://forums.phpfreaks.com/topic/52543-php-join-3-mysql-statements-to-just-one/ Share on other sites More sharing options...
Daniel_Hatcher Posted May 22, 2007 Author Share Posted May 22, 2007 I have this code SELECT a.tid,c.title, c.nid, d.description FROM {term_data} a INNER JOIN {term_node} b INNER JOIN {node} c INNER JOIN {tutorial} d ON d.nid=c.nid WHERE a.vid=$id AND b.tid=a.tid AND c.status=1 AND d.parent=0 Only it displays Creating contact form Example Expert ok intermediate aghh intermediate Creating contact form Example Expert ok intermediate aghh intermediate Creating contact form Example Expert ok intermediate aghh intermediate Creating contact form Example Expert ok intermediate aghh intermediate Creating contact form Example Expert ok intermediate aghh intermediate So you can see it repeats. Quote Link to comment https://forums.phpfreaks.com/topic/52543-php-join-3-mysql-statements-to-just-one/#findComment-259361 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.