Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Posts
    2

    Unanswered: Selecting two columns with diffrent WHERE clause

    Hello,

    I have to write an private message module, so I create this MySQL schema

    id, uid ( who write the message ), subject, message, read ( is read or not ), date

    So! I want to display how many are all the messages and how many are unread messages. Is there any way to do that with a single MySQL query?

    Thank you!
    Marush Denchev

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select count(*) as all_messages
         , count(case when read='n' 
                      then 937 end) as unread_messages
      from daTable
    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
  •