How to get a users list by who created them?

I’ve found it.

/*** Adding extra field to get the the user who creates the another user during ADD NEW USER ***/
function custom_user_profile_fields($user){
    if(is_object($user))
        $created_by = esc_attr( get_the_author_meta( 'created_by', $user->ID ) );
    else
        $created_by = null;
    ?>
    <h3>Extra profile information</h3>
    <table class="form-table">
        <tr>
            <th><label for="created_by">Created By</label></th>
            <td>
                <input type="text" class="regular-text" name="created_by" value="<?php echo $created_by; ?>" id="created_by" /><br />
                <span class="description">The person who creates this user</span>
            </td>
        </tr>
    </table>
<?php
}
add_action( 'show_user_profile', 'custom_user_profile_fields' );
add_action( 'edit_user_profile', 'custom_user_profile_fields' );
add_action( "user_new_form", "custom_user_profile_fields" );

function save_custom_user_profile_fields($user_id){
    # again do this only if you can
    //if(!current_user_can('manage_options'))
      //  return false;

    # save my custom field
    update_user_meta($user_id, 'created_by', $_POST['created_by']);
}
add_action('user_register', 'save_custom_user_profile_fields');
add_action('profile_update', 'save_custom_user_profile_fields');

And then querying the users by the custom field created_by.. That’s it..

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)