What will be the difference in output of these 2 MySQL Queries

Discussion in 'MySQL' started by vishalonne, Apr 3, 2013.

  1. #1
    There is a column Salary in a Table EMPLOYEE. The following two statements are giving different outputs. What may be the possible reason?
    SELECT COUNT(*) FROM EMPLOYEE;
    SELECT COUNT(SALARY) FROM EMPLOYEE;



    This question asked in exam but I am not getting any difference even if I left salary of 1 employee blank
     
    Last edited: Apr 3, 2013
    vishalonne, Apr 3, 2013 IP
  2. vishalonne

    vishalonne Member

    Messages:
    51
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    YES I got answer
    If salary column is defined as NULL and then if any employee's salary is missing then count will skip those null valued record. I got this from http://cbsecsnip.in
     
    vishalonne, Apr 3, 2013 IP
  3. rolodex

    rolodex Well-Known Member

    Messages:
    364
    Likes Received:
    37
    Best Answers:
    5
    Trophy Points:
    175
    #3
    Are you talking to yourself @vishaalonne, hence the nickname? Heheh. Btw, I'm new to PHP.
     
    rolodex, Apr 4, 2013 IP