Results 1 to 4 of 4

Thread: mysql query

  1. #1

    Default mysql query


    Hi need your help mga master

    I have a table 'date_posted' which is in datetime, i want to get the latest records within the week starting from the current date. unsaon ni nako pag query?

    thanks
    Last edited by harvz86; 11-08-2010 at 06:36 PM.

  2. #2
    Elite Member
    Join Date
    Jun 2010
    Gender
    Male
    Posts
    1,018
    Programmatically generated na lang bro ang to and from.
    Kung pseudo code...

    get current date as current...

    get the date seven days before as start...

    query dayon ka...

    select * from sampletable
    where date_posted between (start) and (current)
    order by date_posted desc

  3. #3
    ^^^ Tumpak

    If your mysql version is Mysql 5.0.19 up, you can do it this way bro

    "select * from myTable where date_posted between date_sub(now(), INTERVAL 1 WEEK) and now() order by posted_date desc"

    or if 5 below:

    "select * from myTable where date_posted between date_sub(now(), INTERVAL 7 DAY) and now() order by posted_date desc"
    Last edited by psyche54; 11-09-2010 at 11:02 AM.

  4. #4
    Elite Member
    Join Date
    Jun 2010
    Gender
    Male
    Posts
    1,018
    Quote Originally Posted by psyche54 View Post
    ^^^ Tumpak

    If your mysql version is Mysql 5.0.19 up, you can do it this way bro

    "select * from myTable where date_posted between date_sub(now(), INTERVAL 1 WEEK) and now() order by posted_date desc"

    or if 5 below:

    "select * from myTable where date_posted between date_sub(now(), INTERVAL 7 DAY) and now() order by posted_date desc"
    This one is nice.

  5.    Advertisement

Similar Threads

 
  1. MySQL Query Please Help
    By huskyfritz in forum Programming
    Replies: 4
    Last Post: 11-18-2011, 05:38 AM
  2. MySQL Query Help : Foreign Keys
    By cjoyce12 in forum Programming
    Replies: 0
    Last Post: 01-06-2011, 06:57 PM
  3. mysql help in outfile query
    By kurokotoque in forum Programming
    Replies: 1
    Last Post: 03-13-2009, 12:48 AM
  4. HELP: in MySQL query
    By rastaman81 in forum Programming
    Replies: 19
    Last Post: 01-23-2009, 09:43 PM
  5. Need help MYSQL Query on dynamic table..
    By salbahis in forum Programming
    Replies: 6
    Last Post: 11-15-2008, 11:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top