Yes the order of the clauses in the where statement matter.

First, you want to use indexed fields.  That way, you make full use of
database optimizations.  The execution plan *should* figure it out, but it's
still good practice to use indexed fields first regardless.

Dunno about the second question.

Honestly though, you should use stored procedures where possible.

-----Original Message-----
From: Paul Giesenhagen [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, February 14, 2002 9:03 AM
To: CF-Talk
Subject: cfqueryparam - order of where/and


I read an article by Ben Forta in CFDJ about using <cfqueryparam> I wanted
to test it out, but had a question, well actually two questions.  First has
nothing to do with CFqueryparam

1) Does where/and clauses ORDER matter?  ie

select *
from table
where id = 'xxx'
and data1 = 'xxxx'

Verses

select *
from table
where data1 = 'xxxx'
and  id = 'xxx'

Does one find the information quicker? (switching the where and the and
clauses?).

Which takes me to my second question.  Does the following matter?

select *
from table
where data1 = <cfqueryparam value="#xxxx#" cfsqltype="CF_SQL_VARCHAR"> and
id = 'xxx'

Verses

select *
from table
where id = 'xxx'
and data1 = <cfqueryparam value="#xxxx#" cfsqltype="CF_SQL_VARCHAR">

(Note the where and the and clause switches placement).

Does placement matter?

Thanks
Paul Giesenhagen
QuillDesign
http://www.quilldesign.com
SiteDirector - Commerce Builder


______________________________________________________________________
Why Share?
  Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to