fixed mysql query to get correct p_value