I'm having a difficult time figuring out why my mysql query is returning the same row five times. Here is the query below. I read on here something about joins and cartisian products. I'm very new to this, and editing this query on my site that someone else initially created. Trying to understand the joins that are used here, but it's confusing me. Any help is greatly appreciated. The goal is to get each row to return only once, not five times. Thanks!
SELECT off . * , resp.tracking_date, resp.paid_date, resp.total_value, resp.total_conversion
FROM tbl_offers AS off, tbl_tracking AS tr, tbl_trackvalue AS resp, tbloffers_cat AS offcat
WHERE off.id = tr.offer_id
AND off.offer_type = 'cash_offer'
AND off.id = offcat.offer_id
AND tr.id = resp.tracking_id
AND tr.user_id = '1454'
AND resp.total_value !=0
AND resp.payment_status = 'paid'
LIMIT 0 , 30
Wow, thanks for all the help everyone. Looks like a lot of the solutions mentioned here would work. I did get the result I want by adding a group by tracking_id to the query. Not sure if that's actually the best way to do it or not. I'm just learning to program while editing an old site, which I initially had someone else build. Lot's of fun. The whole join thing is one of the more complicated things I've dealt with so far, but I'm sure it'll get easier.
I'll go through these answers to pick the best one, though it looks like multiple could work, so I'm not sure what the standard method of picking is on this site. Thanks again!
