+ Reply to Thread
Results 1 to 3 of 3

Thread: mysql framming

  1. #1

    mysql framming

    i want to check a table`s number of records where sno=7 , i need to make a boolean value
    i used this code :
    Code:
    select count(*) from tablename where sno = 7
    and then check return value is equal to 7 or not.
    But the ideal query could be the below :
    Code:
    select 1 (else 0) where (select count(*) from tablename ) = 7;

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    30
    There is a simple query for all that
    Code:
    select IF(count(*)=5, 1, 0) as has_5_items from tablename where sno = 7;

  3. #3
    thank you it works

+ Reply to Thread

Bookmarks

Posting Permissions

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