Query conditions workings

HI,

I think the answer may be yes but I need to be sure…

If I query my table, and I have a WHERE and 2 AND clauses; do they each reduce the data set that the next clause has to deal with such that the query becomes leaner as it is processed or; do they all get applied at the same time, at the end of the query?

say I query this


select 
  country
, state
, town
from addresses as AD
left outer join 
possible_countries as PC
on PC.country = AD.country
and PC.state = AD.state
where AD.country = 'France'
AND AD.state = 'Quebec'
and '[mathematical calc here]' 

Will the WHERE & 1st AND reduce the data that the 2nd AND must manipulate?

bazz

i expect all the WHERE conditions on the AD table are processed together, during retrieval of rows from the AD table

whatever rows pass those filters are then matched to PC rows

you can see the sequence of operations by doing an EXPLAIN

p.s. does france actually have a quebec province?

:wink:

Thanks Rudy, I’ll do an explain to try to understand.

lol, no. That was just example data.

bazz