Select fields in multiple tables / change output value / compare fields
I suspect this is what you are looking for 

db_query("SELECT * FROM node LEFT JOIN url_alias ON url_alias.alias=concat('node/',node.nid)");