Using SQL to output link to a node
It's in url_alias table, you'll need concatenate it with your domain name.

SELECT `alias`  FROM `url_alias` WHERE source = "node/XXX";


Note: if you have more than one alias it will return multiple results.