Forum Moderators: open

Message Too Old, No Replies

Mysql resultset in terms of Weeks

Devide the result in terms of weeks

         

anisrehan

10:45 am on Sep 13, 2008 (gmt 0)

10+ Year Member



Dear All
I have a linear database. That is, records of goals in one table, goal_strategy in another table and the goal_student relationship in another table.

What I want to do, is to make a query which reads records from goal_student Table and divide them in terms of weeks, i.e. Week 1, Week 2, Week 3 ......
The question is

How I can do it, using the datetime field which stores the exact time of choosing a goal.

The structure of all the tables are as follows.
------------------------------------------------------------
CREATE TABLE `goal` (
`goal_id` int(11) NOT NULL auto_increment,
`active` tinyint(1) unsigned NOT NULL default '0',
`details` blob NOT NULL,
`title` varchar(255) NOT NULL,
`goal_type` varchar(255) NOT NULL,
PRIMARY KEY (`goal_id`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
------------------------------------------------------------
CREATE TABLE `goal_strategy` (
`goal_strategy_id` int(10) unsigned NOT NULL auto_increment,
`goal_id` int(10) unsigned NOT NULL,
`strategy` varchar(255) NOT NULL,
PRIMARY KEY (`goal_strategy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=latin1;
------------------------------------------------------------
CREATE TABLE `goal_student` (
`goal_student_id` int(10) unsigned NOT NULL auto_increment,
`goal_id` int(10) unsigned NOT NULL default '0',
`userid` varchar(12) NOT NULL default '0',
`start_date` datetime NOT NULL default '0000-00-00 00:00:00',
`curStatus` varchar(45) NOT NULL default '',
`strategy_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`goal_student_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
------------------------------------------------------------

coopster

8:28 pm on Sep 22, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Will the WEEK [dev.mysql.com] function be of any use?

anisrehan

6:54 am on Sep 23, 2008 (gmt 0)

10+ Year Member



Thanks, that's what I am looking for.