|
Posted by Mara Guida on 12/20/05 22:20
John Meyer wrote:
> Okay, I have a database listing various meetings. The meetings have a
> day of the week and a time (Say Sunday at 8:00). Now, given a set of
> these meetings, how would I order them so that they would go Sunday,
> Monday, Tuesday, Wednesday, Thursday, Friday. note these meetings don't
> have dates, just day of week and time. Oh, and they're coming from a
> MySQL database.
create table daysofweek (weekdaynumber int, weekdayname varchar(9));
insert daysofweek values (0, 'Monday');
insert daysofweek values (1, 'Tuesday');
insert daysofweek values (2, 'Wednesday');
insert daysofweek values (3, 'Thursday');
insert daysofweek values (4, 'Friday');
insert daysofweek values (5, 'Saturday');
insert daysofweek values (6, 'Sunday');
Now link your tables together with daysofweek and ORDER BY
weekdaynumber.
If you want the week to start on Wednesdays
select ... order by ((weekdaynumber + 5) % 7)
Navigation:
[Reply to this message]
|