Is there an easier way to print taxonomies in the tpl? I get this working code, but it should be a "shorter" way!
Few things here:


Your SQL is open to injection
You're running a query that has already been run, and for which data has already been returned by the core field system. Drupal already runs way too many queries in a page load, adding another unnecessary one should be avoided wherever possible.
Your code should be in a template preprocess function (or module file as you've mentioned). But that's not because of the length of the code. It's because you should maintain a good separation of logic and display.
Drupal has already prepared the display of the field for you, so it would be preferable to use that instead of building up from scratch again.


With those in mind, try simply adding:

&lt;?php echo render($content['field_name_of_term_ref_field']); ?&gt;


in place of your code.

To control how those field items come out (e.g. as links), navigate to admin/structure/types/manage/TYPE/display, and choose appropriate settings for the display widget.