Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9049873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:30:52+00:00 2026-06-16T12:30:52+00:00

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

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:30:53+00:00Added an answer on June 16, 2026 at 12:30 pm

    This is because data are not mapped in all the 3 tables.

    Below query will work

    select  DATE_FORMAT(l.created_on,"%d/%m/%y") as date
    from logs l
    left join logs_rewards lr on l.id = lr.related_log_id 
    left 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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this very weird issue that I cant really get why it's not
So I have this very weird issue I have found. When I apply a
So, I have this very weird error - Some advanced PHP devs might also
This is very weird. I have the following code: Assert.AreEqual(new DateTime(2000, 1, 1), DateTime.ParseExact(2000,
I have a very weird thing to do and simply don't know how. This
Very strange issue... I have something like this in my Controller: public ActionResult Initialize(IEnumerable<MyModel>
Since iOS6 I have a very weird issue with UIImages that causes the application
I'm having a very weird issue here, I have set-up my solr architecture as
Im having a very weird issue. I have a normal ajax call that upload
Ok...this is very weird. Here is the code for all of my inputs: #sign_in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.