Page 1 of 1

Mysql SELECT help for a beginner

Posted: Mon Nov 21, 2011 11:23 pm
by naveendk.55
I am trying to get result and display them in a particular format. I’m a beginner and hope below discription is clear.

Table Structure is like mentioned below:
ID| Date | Report| Start time | End Time

REPORT Attribute hold any of the three values(Productivity, Monitoring, Break). I want to display the output in below two formats between two selected dates from a form.
a) DATE | Productivity | Monitoring | break| Start Time | End Time.

The report field has the paramenters productivity, Monitoring and Break. If the value has productivity, then it should display in Productivity column, Monitoring value should be displaed in monitoring field. I’m using PHP and Mysql.

b) DATE | Productivity | Monitoring | break| Start Time | End Time.

Here, I want the optput same a above however,the Start time and End time should display the sum of time between the selected dates.

Re: Mysql SELECT help for a beginner

Posted: Tue Nov 22, 2011 1:16 pm
by manohoo

Code: Select all

SELECT
   DATE,
   if( Report = 'Productivity', Report, null) as Productivity,
   if( Report = 'Monitoring', Report, null) as Monitoring,
   if( Report = 'break', Report, null) as break,
   Start Time,
   End Time
FROM ....