Thread: 'AND' in WHERE clauses

'AND' in WHERE clauses

From
James David Smith
Date:
Hi all,

Sometimes I get a bit confused with my AND and OR clauses in WHERE statements. When I'm working with big data I often think it's done one thing and find later it's done another. Given this, would someone just glance at this for me please?  Will this only set the_geom in the condition that ALL of my WHERE clauses are satisfied?  ( I hope so)

UPDATE stage SET the_geom = st_setsrid(st_makeline(st_makepoint(soose::integer, soosn::integer), st_makepoint(sdose::integer, sdosn::integer)),27700) WHERE sdurn::numeric = 0 AND bad_flag IS NULL AND smode5y = '1'  AND st_length(st_makeline(st_makepoint(soose::integer, soosn::integer), st_makepoint(sdose::integer, sdosn::integer))) < 60;

Thanks

James

Re: 'AND' in WHERE clauses

From
Albe Laurenz
Date:
James David Smith wrote:
> Sometimes I get a bit confused with my AND and OR clauses in WHERE statements. When I'm working with
> big data I often think it's done one thing and find later it's done another. Given this, would someone
> just glance at this for me please?  Will this only set the_geom in the condition that ALL of my WHERE
> clauses are satisfied?  ( I hope so)
> 
> UPDATE stage SET the_geom = st_setsrid(st_makeline(st_makepoint(soose::integer, soosn::integer),
> st_makepoint(sdose::integer, sdosn::integer)),27700) WHERE sdurn::numeric = 0 AND bad_flag IS NULL AND
> smode5y = '1'  AND st_length(st_makeline(st_makepoint(soose::integer, soosn::integer),
> st_makepoint(sdose::integer, sdosn::integer))) < 60;

Yes, all clauses joined with AND have to be satisfied for the condition to be true
and for the update to happen.

Yours,
Laurenz Albe

Re: 'AND' in WHERE clauses

From
James David Smith
Date:
Thanks.


On 10 December 2013 15:23, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
James David Smith wrote:
> Sometimes I get a bit confused with my AND and OR clauses in WHERE statements. When I'm working with
> big data I often think it's done one thing and find later it's done another. Given this, would someone
> just glance at this for me please?  Will this only set the_geom in the condition that ALL of my WHERE
> clauses are satisfied?  ( I hope so)
>
> UPDATE stage SET the_geom = st_setsrid(st_makeline(st_makepoint(soose::integer, soosn::integer),
> st_makepoint(sdose::integer, sdosn::integer)),27700) WHERE sdurn::numeric = 0 AND bad_flag IS NULL AND
> smode5y = '1'  AND st_length(st_makeline(st_makepoint(soose::integer, soosn::integer),
> st_makepoint(sdose::integer, sdosn::integer))) < 60;

Yes, all clauses joined with AND have to be satisfied for the condition to be true
and for the update to happen.

Yours,
Laurenz Albe