Database:
Table_Sensor:
sensor_id,
sensor_name
Table_Sensor_Detection:
sensor_id
azimuth (azimuth from specific sensor)
Users have the possibility to enter multiple Sensors, so I have defined Set < Integer> sensorsSet
.
Users also have the possibility to enter azimuth for each sensor
, so i have Sensor.azimuth
, for each sensor.
All I need is logic for SQL statement that will give me all sensor_detections
for entered sensors_ids
, and another query for the adequate azimuth for each sensor.
This is List< String> queryList
that describe logic I want accomplish.
for(Integer enteredSensorId:sensorsSet)
{
querysList.add(
"SELECT s FROM Table_Sensor_Detection s " +
"WHERE s.sensor_id="+enteredSensorId +
"AND s.azimuth"=getAzimuthForSenzor(enteredSensorId)
);
}
The code above is simplified, so don't bother with possible mistakes. I only want to found out what is best approach to solve this problem:
a) create multiple SQL queries, run them separately and merge results (similar to code above),
b) create one SQL query (best solution if it is possible),
c) something else (what?)?