Fix user querying for note using custom SQL