I have this query derived from original query, original query has 50 records and the qoq should give me 30 rows, but it is giving me full 50 rows,
what i am doing here
here is my Query of Query
<cfquery name="qryResults" dbtype="query">
Select *
From qryResults
Where sDate> {d '2015-01-01'}
OR (
userID = 22
AND isActive = 1
)
OR (
userID = 8
AND isActive = 0
)
OR (
userID = 7
AND isActive = 1
)
</cfquery>
what i am doing wrong in here
This question needs more detail about the result set retrieved and what's contained in the original 50 row result set. Without knowing those details, it's hard to determine why no rows are being filtered out. However, considering you're using the OR
for all of your operator connecting conditions, then what happens is that only one condition needs to satisfy returning all 50 rows. I'm going to take a stab at this and presume the culprit is the date comparison since the rest are more specific about requiring the correct combination of userID
and isActive
. My best "guess" is that you likely need to change the first OR
in your where clause into an AND
with the final result looking like this.
<cfquery name="qryResults" dbtype="query">
Select *
From qryResults
Where sDate> {d '2015-01-01'}
AND (
userID = 22
AND isActive = 1
)
OR (
userID = 8
AND isActive = 0
)
OR (
userID = 7
AND isActive = 1
)
</cfquery>