
This is my database tables representation.
I am doing inner join to get the data from these tables the query is as follows.
Query-1
select * from Trips
Inner join TripPoints
On Trips.tripkey=Trippoints.tripkey
inner join Cars
On Trips.carid=Cars.cid
and Cars.cid IN ('1','2','3','4','5','6')
where (lat>='4.0' and lat<='5.0')
and
(long>='52' and long <='54')
Query-2
for(int carId=1;carId<=6;carId++)
{
select * from Trips
Inner join TripPoints
On
Trips.tripkey=TripPoints.tripkey
inner join Cars
on
Trips.carid=Cars.cid and CARS.cid = carId
where
(lat>='4.0' and lat<='5.0')
and
(long>='52' and long <='54')
}
Both queries executes successfully.
But Query-1 gives lesser records than that of Query-2 ?
What difference in the query makes result difference?
forloop structures?