You can find several suitable queries in data explorer or create your own query. (Even for users who do not know much about SQL, it's not that difficult to look up basic info on the database schema and then try to modify the existing queries.)
Some queries for finding comments by User1 on posts by User2:
Questions asked by User1 and answered by User2:
And there is also this interesting much more general query: Have we met?
The usual caveat applies: Data in SEDE are only updated once a week.
Of course, you can use these queries not only for MathOverflow, but also for other sites in Stack Exchange network. (You can simply click on switch sites and choose, for example, this meta or Mathematics.)
You will need UserId of both users you are interested in, which you can find from their profiles. See also: What is my user ID? (Perhaps it is also worth mentioning that the same user has different id on different sites. I.e., your id on MathOverflow is not the same as your id on Mathematics, StackOverflow, etc.)
To include some example with UserIds, I have tried some rather active users, so that there will be at least some results.
To answer the second part of your questions about database queries in general: You can find links to some basic info about data explorer in the corresponding tag-info. And you can also have a look at some past question on this meta tagged statistics or data-explorer - you will find out that in several of them data explorer have been used. Also some other posts with contain the url of data explorer or the string sede are likely candidates for posts where you can see data explorer at work.
And since you also asked about more sophisticated search tricks, I'll add that you can find some of them in the help center and directly on the search page (you have to click on Advanced Search Tips). However, this is about the built-in search and completely unrelated to data explorer. In particular, the built-in search has possibility to restrict search to posts by specific user by using
user:UserId or user:me. However, it only searches in posts, not in comments.