\documentclass[12pt]{article}

\begin{document}

\section{1}


\section{2}

\subsection{2.1}

\begin{table}[here]
\begin{center}
\begin{tabular}{c}
da \\
\end{tabular}
\end{center}

\label{foo}
\caption{foo}
\end{table}

This is a reference for table~\ref{foo}.

\end{document}

