----- Original Message ----- 
From: "darrell troth" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 26, 2004 3:29 PM
Subject: Date query and date removal


> This will seem an easy question, but I cannot find a sample anywhere:
> I have a database of bands appearing at a club. I want to update the list
sorted by date and have the results only show current date and beyond
(i.e. - remove band that played last night from results page). This query is
driving me nuts and only thing left to finish a site.
>

I just realized that I misread your initial post; you don't just want to
*see* future performances, you want to delete past ones.

Here is a quick script I knocked together to demonstrate the solution. When
I run the first SELECT, I get all of the performances listed in
chronological order. Then, the delete gets rid of all performances that have
already taken place. When I run the second SELECT, I get only the
performances that occur today or in the future, specifically Pat Metheny and
Yes, listed in chronological order.

-------------------
use tmp;

drop table if exists performances;
create table if not exists performances
(performer char(30) not null,
 performance_date date not null,
 primary key(performer, performance_date));

insert into performances values ('Pink Floyd',  '2004-11-04');
insert into performances values ('Pat Metheny', '2004-11-26');
insert into performances values ('Yes',         '2004-11-30');

select * from performances
order by performance_date;

delete from performances
where performance_date < current_date();

select *
from performances
order by performance_date;

-------------------



Rhino


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to