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 !

 

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.