MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » October 2004

Like vs. =



fixed

Dan,  

You wrote:
**************************************************************************
I am setting up a dynamic SQL statement based on user input for data
selection.  They are able to select using wildcards, so I am using the
LIKE
predicate to handle this.

My question is this:  When the user doesn't specify wildcards, and
specifies
a "straight" value, is there any difference between using LIKE and an
equal
sign?  I.e.:

CUSTNAME LIKE 'BALE, DAN'
CUSTNAME = 'BALE, DAN'
*************************************************************************

Yep, a big difference.   Equal (=) uses indexes if possible, LIKE may
or may not.  LIKE uses more resources.   While its useful, its more
costly.   Equal would be a better choice if at all possible.

Further, likewise, it more costly to use dynamic SQL vis. static SQL.  
I'd stay away from dynamic SQL when possible.

But, if you have a powerful machine or the table your search is small
or the dynamic and LIKE usage is small, perhaps you won't be effected
much.

Dave
Arizona





Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact