this is a very weird issue.
I have 3 tables, all with key relations on agent\_id.

Now this query :

```
select DATE_FORMAT(created_on,"%d/%m/%y") as date
from logs
where agent_id = "18"
and log_status="1"
and date_format(created_on,"%m/%y") = "12/12"
group by YEAR(created_on), MONTH(created_on), DAY(created_on) desc

```

Does exactly what it suppoused to, it returns 3 rows of :

```
date
31/12/12
30/12/12
26/12/12

```

However when I join 2 other tables it excludes the date of `31/12/12`. This is the query :

```
select  DATE_FORMAT(l.created_on,"%d/%m/%y") as date
from logs l
join logs_rewards lr on l.id = lr.related_log_id 
join agents a on a.id = l.agent_id 
where l.log_status = "1" 
and DATE_FORMAT(l.created_on,"%m/%y") = '12/12'
AND l.agent_id = '18' 
group by YEAR(l.created_on), MONTH(l.created_on), DAY(l.created_on) desc

```

This returns :

```
date
30/12/12
26/12/12

```

And I can't figure out why that happens. Any help?

I've tried changing `AND l.agent_id = '18'` to `AND a.id = '18'` but same result.