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

  • Home
  • SEARCH
  • 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 7736629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:47:14+00:00 2026-06-01T07:47:14+00:00

All, I need your help to merge the result in the same datetime in

  • 0

All,

I need your help to merge the result in the same datetime in mysql.

I do a query of two tables like :

SELECT b.ID, b.DateTime, b.Value 
FROM tableA a, tableB b 
WHERE (a.Id=1) OR (a.Id=2) OR (a.Id=3) AND (a.Id = b.ID) 
      AND (b.DateTime Between '2011-04-02 06:00' And '2011-04-02 06:05')

Query result :

| ID  |    DateTime      | Value |
----------------------------------
| 1   | 2011-04-02 06:00 | 20    | 
| 1   | 2011-04-02 06:05 | 21    | 
| 2   | 2011-04-02 06:00 | 10    | 
| 2   | 2011-04-02 06:05 | 16    | 
| 3   | 2011-04-02 06:00 | 23    | 
| 3   | 2011-04-02 06:05 | 22    |

All i want is to make a result like :

|    DateTime      | ID_1    | ID_2   | ID_3   | 
------------------------------------------------
| 2011-04-02 06:00 |  20     |   10   | 23     | 
| 2011-04-02 06:05 |  21     |   16   | 22     | 

I hope there is a solution for this.

Thank you before for all your help.

Regards,
YougyZ

  • 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-01T07:47:15+00:00Added an answer on June 1, 2026 at 7:47 am

    Thanks @liquorvicar for the solution…

    I have tried this query :

    SELECT b.Date, 
    SUM(CASE WHEN a.Id=1 THEN b.Value ELSE 0 END) AS Mac1, 
    SUM(CASE WHEN a.Id=2 THEN b.Value ELSE 0 END) AS Mac2, 
    SUM(CASE WHEN a.Id=3 THEN b.Value ELSE 0 END) AS Mac3 
    FROM TableA a, TableB b 
    WHERE (a.Id = b.ID) AND (b.Date Between '2011-04-02 06:00' And '2011-04-02 06:05') 
    GROUP BY b.DA_Date 
    

    The Result is just like what i need.. 🙂

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

Sidebar

Related Questions

Afternoon all, I really need your help as this is a Nightmare! I was
I need your help to optimize the query to avoid using Using filesort.The job
Need your help guys in forming a query. Example. Company - Car Rental Table
Hi guys I really need your help All I want to do is to
I need your help with my database design. I'm trying to develop a Result
I need your help to clarify whether form work exactly like object? If I
i need your help. I have two forms, Form1 and Form2. In Form1 i
I need your help. I have tables using PHP while looping and I need
hello all i really need your help its my final project in university i
Greeting all wise man! I really need your help here as I'm new to

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.