#173 Changes Query to get XID from same connection, added database

clouse in query to find xid for same database