Jump to content

Newbie: need help with formulating a Query


vincej

Recommended Posts

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 !

 

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.