I have a table as below,
process_name | startTime | endTime | parent_id
-------------------------------------------------------------------------
chrome | 2019-03-06 00:48:27 | 2019-03-06 00:48:58 | 111
chrome | 2019-03-07 00:48:27 | 2019-03-07 00:48:58 | 112
firefox | 2019-03-08 00:48:27 | 2019-03-08 00:48:58 | 113
IE | 2019-03-09 00:48:27 | 2019-03-09 00:48:58 | 114
firefox | 2019-03-10 00:48:27 | 2019-03-10 00:48:58 | 115
chrome | 2019-03-11 00:48:27 | 2019-03-11 00:48:58 | 116
Some points from the table,
Same
process_namecan be found under differentparent_ids.I already know the
process_nameand have anArrayListofparent_idswhere it exists.
For a given process_name, I need to find startTime and endTime for all of the parent_ids present in my ArrayList.
All I can think of is using a for loop and execute the below query.
select startTime, endTime from myTable where parent_id = ? and process_name=?
Can I avoid executing this query in a loop and follow some other better approach?
I use Derby at this moment but the DB may get changed to Oracle.