# Enumerating listings in LaTeX breaks the list [closed]

Why is enumerating listings in LaTeX causing numbers in the list to be displayed in the wrong place? The following code prints the first and third list numbers in the correct place, but prints the second list number in the same place as the third and doesn't print the fourth at all.

\documentclass[titlepage]{article}
\usepackage{listings}
\begin{document}
\begin{enumerate}
\item
\begin{lstlisting}
SELECT * FROM foo;
\end{lstlisting}
\item
\begin{lstlisting}
SELECT * FROM bar;
\end{lstlisting}
\item
\begin{lstlisting}
SELECT * FROM foobar;
\end{lstlisting}
\item
\begin{lstlisting}
SELECT * FROM barfoo;
\end{lstlisting}
\end{enumerate}
\end{document}

-
Are you sure you want to use the lstlisting environment and not the \lstinline macro? –  egreg Dec 3 '12 at 13:27
Thanks @egreg, that fixed my problem and is a neater solution. –  Nic Dec 3 '12 at 13:43