You are here: Re: Quick and simple way to order a set of meetings by day of week « PHP Programming Language « IT news, forums, messages
Re: Quick and simple way to order a set of meetings by day of week

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация