Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    35

    Question Unanswered: Help with HOUR() query

    Hello,

    I have a quick question.

    In mySQL you can do the following, where messages.date is a datetime column:

    Code:
    SELECT HOUR( date ) AS time FROM messages;
    I would like to select all columns from messages, where HOUR( date ) = 1 for example. How do I do this? Also, how would I issue a count?

    ex in english:

    "Select the column count AS total FROM messages WHERE HOUR( messages.date ) is 1"

    Thanks in advance for your help.
    Alexandre

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Atari
    I would like to select all columns from messages, where HOUR( date ) = 1 for example. How do I do this? Also, how would I issue a count?
    what do you mean by "issue a count"? you mean a count of the number of rows that have the hour equal to 1? that would give you a one-row answer, and you can't get that at the same time as the columns
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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