I have a Process table, with basic data and other ProcessesDestaque, with more specific data. I need to make a select that calls some columns of the basic data and some of the specific data. I tried to make a list, but I can only call the data from just one table.
In the first Process table, I have the following columns: codGeral,classeProc, numProc, autorProc, ResumoProc
.
The ProcessesDestaque table has the following columns: codDest, codGeral(chave estrangeira), ementaProc, dispProc
.
The listarDest method looks like this:
public List listarDest()
{
List lst= new ArrayList<>();
List lstDest = newArrayList<>();
try
{
stmt = con.prepareStatement(“SELECT codigoGeral.Processos, classe.Processos, numProc.Processos, autor.Processos, codDest.ProcessosDestaques, ementaProc.ProcessosDestaque FROM ProcessosDestaque JOIN Processos ON ProcessosDestaque.codGeral = Processos.codGeral”);
rs = stmt.executeQuery();
while(rs.next())
{
ProcDestaques procdestaques = new ProcDestaques();
Proc proc = new Proc();
procdestaques.setCodDest(rs.getInt(1));
procdestaques.setCodGeral(rs.getInt(2));
proc.setClasse(rs.getString(3));
proc. setNumProc(rs.getString(4));
proc.setAutor(rs.getString(5));
procdestaques.setEmentaProc(rs.getString(6));
lstDest.add(procdestaques);
lst.add(proc);
}
stmt.execute();
rs.close();
con.close();
}
catch (SQLException e)
{
throw new RuntimeException(e);
}
return lstDest;
}
Does anyone have any idea how to do the select return the data of the two tables?