Filter in consultation

Asked

Viewed 39 times

-1

modelo.setNumRows(0);
    Class.forName(Auxiliar.AcessoBanco.getDriver());
    Connection con = DriverManager.getConnection(Auxiliar.AcessoBanco.getUrl(), Auxiliar.AcessoBanco.getUser(), Auxiliar.AcessoBanco.getPass());
    String query1 = "Select id_ct, ORDEM ,CDLINHA, TIPOL,SETOR ,TCPERFIL,BPCS,DPERFIL ,PROJETO ,OEM,N_DESENHO ,N_PLANO,OPERACAO,EQUIPAMENTO, DESCTESTE,COMPLEMENTO, TCTESTE ,"
            + "ESPEC_MIN,ESPEC_MAX, ESPEC_UNID,ESPEC_TEXTO,REFERENCIA,"
            + "FREQUENCIA,FREQ_UNID,PRODUTO,ORIGEM,TIPO,ESPECTEXTO,"
            + "FREQTEXTO,LAB from QRY_RESULT where TCPERFIL = " + txt_perfil.getText() + "ORDER BY ORDEM asc";

As you can see.. i do a search for a "Profile" that contains several tests registered in it, but now I need to filter the tests that are related to "LAB" column and that are "Yes" so that the person in the lab only put the values in the laboratory test. Can anyone tell me how I add this search in this query?

  • Information is missing there. Do you have this table QRY_RESULT and are you trying to filter the records that contain the value "LAB" in a specific column? Try to explain better!

  • Next. i have a Defaulttablemodel where I bring several tests related to a "profile" q is specified "TCPERFIL = " + txt_perfil.gettext() +", only that now I need to bring only some tests related to "LAB" column that contains the value "Yes". and bring to registered person

  • "LAB" column is a column in the database?

  • That and it has values "Yes, No"

  • I answered there. pass the feedback

1 answer

1


To bring only the records with the column LAB equal to Sim.

Modify your query to:

String query1 = "Select id_ct, ORDEM ,CDLINHA, TIPOL,SETOR ,TCPERFIL,BPCS,DPERFIL ,PROJETO ,OEM,N_DESENHO ,N_PLANO,OPERACAO,EQUIPAMENTO, DESCTESTE,COMPLEMENTO, TCTESTE ,"
            + "ESPEC_MIN,ESPEC_MAX, ESPEC_UNID,ESPEC_TEXTO,REFERENCIA,"
            + "FREQUENCIA,FREQ_UNID,PRODUTO,ORIGEM,TIPO,ESPECTEXTO,"
            + "FREQTEXTO,LAB from QRY_RESULT where TCPERFIL = " + txt_perfil.getText() + " and LAB = 'Sim' ORDER BY ORDEM asc";

adding and LAB = 'Sim'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.