vincej Posted January 20, 2012 Share Posted January 20, 2012 Hi - I have a query where I am pulling data from 3 tables. I'm using a 'foreach' to pull the data out of the results. My query works but . The problem is that when presented in a report the results include 3x duplication of each value. I could break up the query into 3 BUT, then that will screw up my form. I do not want 3 submit buttons where each submit accepts data to each table. I want 1 submit. Here is the query: SELECT recipies.id, recipies.title AS 'Recipie Title' , recipies.summary AS 'Recipie Summary', recipies.image , recipies.status AS 'Recipie Status', comments.id, comments.title ,comments.summary, comments.body, comments.status,comments.createdate,comments.createuser,comments.customerid,recipies.createdate, `firstname` , `lastname` FROM `recipies` , `customer`,`comments` WHERE recipies.customerid = customer.id AND recipies.status =1 LIMIT 0 , 30 "; THANK YOU VERY MUCH FOR ALL YOUR HELP ! Link to comment https://forums.phpfreaks.com/topic/255439-newbie-need-help-with-formulating-a-query/ Share on other sites More sharing options...
vincej Posted January 20, 2012 Author Share Posted January 20, 2012 for the sake of clarity I want to get rid of the duplication in the results - thanks !!!! Link to comment https://forums.phpfreaks.com/topic/255439-newbie-need-help-with-formulating-a-query/#findComment-1309649 Share on other sites More sharing options...
awjudd Posted January 20, 2012 Share Posted January 20, 2012 SELECT DISTINCT r.id, r.title AS 'Recipe Title' , r.summary AS 'Recipe Summary', r.image , r.status AS 'Recipe Status', c.id, c.title ,c.summary, c.body, c.status,c.createdate,c.createuser,c.customerid,r.createdate, `firstname` , `lastname` FROM `recipies` AS r JOIN `customer` AS cu ON r.customerid = cu.id JOIN `comments`AS c ON cu.id = c.customerid WHERE r.status =1 LIMIT 0 , 30 Link to comment https://forums.phpfreaks.com/topic/255439-newbie-need-help-with-formulating-a-query/#findComment-1309689 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.