List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:August 9 1999 10:26pm
Subject:Re: mysql-query
View as plain text  
On Mo, 1999-08-09 11:49:47 +0530, Ranjeet Walunj wrote:
> here is my sample info table
> ------------------
> name    | send_date
> -----------------
> ranjeet | 1999-08-06
> rakesh  | 1999-07-05
> vidya  | 1999-07-26
> prachi | 1999-05-21
> -----------------------
> 
> now i want to write a query which will delete records older than 15
> days

This gives you records with a send_date older than 15 days:

 SELECT *
 FROM   info
 WHERE  send_date < SUBDATE(CURRENT_DATE, INTERVAL 15 DAY);

Another possibility:

 SELECT *
 FROM   info
 WHERE  TO_DAYS(CURRENT_DATE)-TO_DAYS(send_date) > 15;

Just do the same for your DELETE statements ...

>        can we write a nested query in mysql...??

No, not yet.

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
mysql-queryranjeet walunj9 Aug
  • MySQL and Perlksausw9 Aug
    • Re: MySQL and PerlRichard K. Moore9 Aug
      • RE: MySQL and PerlEe Loon13 Aug
  • Re: mysql-queryMartin Ramsch10 Aug
Re: MySQL and Perlluuk9 Aug
RE: MySQL and PerlPaul DuBois13 Aug
  • RE: MySQL and PerlStuart D Jackson13 Aug