Forum Moderators: open

Message Too Old, No Replies

mysql query help

writing an advanced query

         

iancos

10:53 pm on Jan 10, 2009 (gmt 0)

10+ Year Member



hi everyone - i'm trying to write a query and the part that's a little crazy is that it works great on my local machine but then gives different results when i upload it to my hosted database (godaddy). i'm stumped... i synced the data in the two databases to be exactly the same.

is there anything about this query which would be interperted differently by two different database servers?

here's the query:

select c.id, c.fname, c.lname,
(select count(distinct p.id) from gteams.points p
join team_map tm on tm.celebrity_id = p.celebrity_id
where p.date > date_add(l.begin_date, INTERVAL 0 DAY)
and p.date < date_add(l.begin_date, INTERVAL 7 DAY)
and p.celebrity_id = c.id and tm.team_id=t.id
and
case when tm.date_removed is null
then p.date > tm.date_added
else (p.date > tm.date_added AND p.date < tm.date_removed)
end) as week_1_points,
(select count(distinct p.id) from gteams.points p
join team_map tm on tm.celebrity_id = p.celebrity_id
where p.date > date_add(l.begin_date, INTERVAL 7 DAY)
and p.date < date_add(l.begin_date, INTERVAL 14 DAY)
and p.celebrity_id = c.id
and tm.team_id=t.id and
case when tm.date_removed is null
then p.date > tm.date_added
else (p.date > tm.date_added AND p.date < tm.date_removed)
end) as week_2_points
from gteams.team t
join gteams.team_map tm on tm.team_id = t.id
join gteams.celebrity c on c.id = tm.celebrity_id
left join gteams.points p on p.celebrity_id = c.id
join gteams.league l on l.id = t.league_id
where t.id = 27
group by c.id

coopster

8:59 pm on Jan 14, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, iancos.

Have you compared the server versions running on each box? I see subselects and wonder if they are part of the problem ... but you said both are running, just returning different result sets. Are you getting any errors?

belfasttim

11:35 pm on Jan 21, 2009 (gmt 0)

10+ Year Member



Also check your timezones on the different boxes-- sounds like you're looking for rows based on time of update/creation, and if the server is in a different time zone you'd get different results.