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 8340175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:06:28+00:00 2026-06-09T05:06:28+00:00

I have some records in database. Now I want to get the record from

  • 0

I have some records in database. Now I want to get the record from date wise. Please see the below format of my table.

 User_id    name    date         Present
  001      Jone    01-08-2012     yes
  002      arun    01-08-2012     yes
  001      Jone    02-08-2012     yes
  002      arun    02-08-2012     yes
  001      Jone    03-08-2012     yes
  001      Jone    04-08-2012     yes
  002      arun    05-08-2012     yes
  001      Jone    05-08-2012     yes
  001      Jone    06-08-2012     yes
  001      arun    06-08-2012     yes

I want get “arun” report from 01-08-2012 to 07-08-2012 like this

 User_id    name    date         Present
  002      arun    01-08-2012     yes
  002      arun    02-08-2012     yes
  002      arun    03-08-2012    
  002      arun    04-08-2012     
  002      arun    06-08-2012     yes
  002      arun    07-08-2012     
  • 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-09T05:06:29+00:00Added an answer on June 9, 2026 at 5:06 am

    In order to display the missing date, you would need a temp table.
    temp table:

    CREATE TABLE numbers (number INTEGER);
    INSERT INTO numbers VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9);
    

    sql as below:

    SELECT CASE WHEN u.id IS NOT NULL 
           THEN u.id
           ELSE u2.id
    END AS id ,
    CASE WHEN u.name IS NOT NULL 
           THEN u.name
           ELSE u2.name
    END AS name ,
    cal.date, 
    CASE WHEN u.present IS NOT NULL 
           THEN u.present
           ELSE ''
    END AS present 
    FROM (
        SELECT '2012-08-01' + INTERVAL a.number * 10 + b.number DAY as date
        FROM numbers a JOIN numbers b
        ORDER BY a.number * 10 + b.number
    ) cal LEFT JOIN (select * from users where name='arun') u 
    ON DATE_FORMAT(STR_TO_DATE(u.date1, '%d-%m-%Y'), '%Y-%m-%d') = cal.date
    left join (select id,name from users  group by id)u2 on u.id is null and u2.name='arun'
    WHERE date BETWEEN '2012-08-01' AND '2012-08-07';
    

    SQL DEMO HERE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose i have 1kk records in my database. Now i need to select some
I have a table within my database that has many records, some records share
I have a database that has around 10k records and some of them contain
I have some XML which contains records and sub records, like this: <data> <record
I want to delete records from a database when they are 7 days or
I have developed an application that pulls X amount of records from my database
I have some records inside an ObservableCollection. void proxy_AddPayNowOrderCompleted(object sender, AddPayNowOrderCompletedEventArgs e) { listBox1.ItemsSource
I have some records like this: ID Personel_Code Time --- ------------- ------ 1 0011
I have some records after SQL generating: YEARS MONTHS SUMMONTH SUMQUARTER QTR ----- ------
I have some dirty resource usage records in t_resourcetable which looks like this resNo

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.