Cross database querying if both databases are in the same AG is easy. We just use standard 3 part naming:
SELECT t1.ID
FROM [database1].[dbo].[table1] t1
JOIN [database2].[dbo].[table2] t2 ON t1.ID = t2.ID
How does this work, or can it work if database1 and database2 are in different availability groups? Do I have to create a Linked Server that references the other AG Listener or this is just something that's not possible?