I have a sql query that gets generated froman asp page, depending on what a user selects.
There could be any amount of :
- UserID 's
- Vehicles_Trips.VID 's
and the trip_diff and Mil_diff will be "<" or ">" a certain amount.
When I create the list of UserID's or VID's I use "or", and the other two I use "and", but this dosn't seem to be working. Example code below, this code still selects records where trip_diff and Mil_diff are over 50, which it should not.
(I have tried using all and's, and all or's - dosnt work either)
can anyone see where my and's / or's are not working correctly Thanx.
There could be any amount of :
- UserID 's
- Vehicles_Trips.VID 's
and the trip_diff and Mil_diff will be "<" or ">" a certain amount.
When I create the list of UserID's or VID's I use "or", and the other two I use "and", but this dosn't seem to be working. Example code below, this code still selects records where trip_diff and Mil_diff are over 50, which it should not.
(I have tried using all and's, and all or's - dosnt work either)
can anyone see where my and's / or's are not working correctly Thanx.
Code:
Select * from Vehicles_Trips left join Vehicles on Vehicles.VID = Vehicles_Trips.VID where Vehicles_Trips.VID= 3 or Vehicles_Trips.VID= 5 or UserID = 964 and Mil_diff < 50 and trip_diff < 50 order by Make, Start_Mil