Absolutely. You just need to make sure to reference each piece with the 3 or 4 part name.
Database.Schema.Table when referencing tables
and
Database.Schema.Table.Column when referencing columns
You can write joins between databases this way and deffinately pull data from more than one database.