This snippet shows you how to get a single query result as string in Drupal 7, using select from database abstraction layer.
Source code viewer
->condition('u.username', $username) ->execute() ->fetchCol()); // Now that you have a single value, you can use it to load an entity for an example. $user = user_load($uid);Programming Language: PHP