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.
It looks like you're new here. Sign in or register to get started.