Mysql SELECT help for a beginner

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
naveendk.55
Forum Newbie
Posts: 24
Joined: Tue Aug 16, 2011 10:13 am

Mysql SELECT help for a beginner

Post 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.
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: Mysql SELECT help for a beginner

Post 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 ....
Post Reply