Something like:
$sql = "SELECT agent_id FROM user_agents WHERE user_agent_string = '".$_SERVER['HTTP_USER_AGENT']."';";
may work, provided the user agent is an exact match.
Another, more flexible - but also more intensive - way would be to load them all (select * from user_agents) into an array, then use a foreach to loop through them until you hit a match with preg_match or a simple string comparison.
If you provide a bit more information about how you're storing the data and some examples of what exactly you're comparing against, we could help you a bit more. Always helps if you post any code you're working with.