Search code examples
javaloopsnested-loops

Tricky loop through database entries in a JAVA method


I'd like to loop through the following table (this loop is not the problem) enter image description here

The method should return "success" to me, if one of the items with the same IDs (ID1 and ID2) is on success and all other items are also on success. See the picture above one 7 - 7 is on failed and one 7 -7 is on success so this should return success. But only, if the other entry in the db (ID1 = 7 and ID2 = 8) is also on success.

Is there a way to do this?


Solution

  • you should use query like

    select status from table1 where table1.ID1= table1.ID2;
    

    than after you should check status for success or failure in your for loop