Don't, if you can avoid it.
A simple JIRA filter for something like "project = xxx" will find your issues. Then include the Epic Link in the issue navigator output, along with other fields.
Doing this via the database means reading at least 4 tables (and I think it might actually be 6). It's hard, slow and may change. There's far easier routes - use them.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.