enigma1 - 9:06 am on May 4, 2011 (gmt 0)
You will have to know some sort of separator for the user agent string. For example if space is a separator you could create an array of the UA elements
$ua = $_SERVER['HTTP_USER_AGENT'];
$ua = preg_replace('/\s\s+/', ' ', trim($ua));
$ua_array = explode(' ', $ua)
So now you have the parts of the UA in an array and you could run the regexp or use the in or like operators,
"select ...... where bot_user_agent in (" . implode(',', $ua_array) . ")"
You could add another pass on the ua array to filter out elements that are unlikely to represent a user agent (elements with less than 10 chars etc).