Any MySQL gurus here?

Discussion in 'OT Technology' started by Hediir, Dec 7, 2007.

  1. Hediir

    Hediir New Member

    Joined:
    Oct 9, 2007
    Messages:
    190
    Likes Received:
    0
    Location:
    Your heart
    In a following query what does "having code like "%0%";" mean?
    select code, count(grade) from grades group by code having code like "%0%";
     
  2. retorq

    retorq What up bitch??

    Joined:
    Dec 14, 2006
    Messages:
    6,061
    Likes Received:
    0
    Location:
    Mohave Desert
    Means having 0 anywhere in that field.
     
  3. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    HAVING is like WHERE
     
  4. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
  5. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    for group by functions... the difference is the where filters BEFORE the grouping, and having filters results after
     
  6. Pork Chop Sandwiches

    Pork Chop Sandwiches Extraordinary Member

    Joined:
    Feb 25, 2005
    Messages:
    7,217
    Likes Received:
    0
    Location:
    TGP
    HAVING filters the results of an aggregate function. In T-SQL, the code above would error out because you aren't applying HAVING to the results of the aggregate function. If the code above works in MySQL then MySQL must use HAVING differently. If you want to count only the grades with a code that has 0 in it, then filter it out in the WHERE clause.
     

Share This Page