Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010
    Posts
    39

    Unanswered: How do i select current program from this table

    I am trying to select current program (which is happening now) from this table. Please help Thanks.

    Code:
    CREATE TABLE `programs` (
     `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
     `p_day` varchar(20) NOT NULL,
     `program` varchar(255) NOT NULL,
     `p_start` time NOT NULL DEFAULT '00:00:00',
     `p_end` time NOT NULL DEFAULT '00:00:00',
     PRIMARY KEY (`id`)
    )

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    What determines the "current-ness" for your purposes?

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT p_p.id 
         , p_p.p_day 
         , p_p.program 
         , p_p.p_start 
         , p_p.p_end 
      FROM programs AS p_p 
     WHERE p_p.p_day = DATE_FORMAT(CURRENT_DATE,'%W)
       AND CURRENT_TIME BETWEEN p_p.p_start AND p_p.p_end
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •