Vertical alignment of listings in tables, with hyperref

I can't get listings to vertically align at the top of table cells. Here's an example.

\documentclass{article}
\usepackage{hyperref}
\usepackage{listings}

\begin{document}
\begin{tabular}{ll}
$q_{1}:$ & \begin{lstlisting}[language=SQL, boxpos=t]
SELECT *
FROM mytable
\end{lstlisting}
\end{tabular}
\end{document}


I'm using boxpos=t. If I comment out \usepackage{hyperref} then I get the alignment I want (text and listing top-aligned). But otherwise it produces the following output:

How can I achieve top-aligned cells, while using hyperref?

• Probably unrelated to the question, but hyperref should generally (with a few exceptions) be the last package in the preamble. – leandriis Oct 19 '19 at 12:07

Try the following:

\documentclass{article}
\usepackage{listings}
\usepackage{hyperref}

\begin{document}
\begin{tabular}{lp{0.5\linewidth}}
$q_{1}:$    &   \vspace{-\baselineskip}
\begin{lstlisting}[language=SQL, boxpos=t]
SELECT *
FROM mytable
\end{lstlisting}
\end{tabular}
\end{document}