Skip to main content
Known Participant
December 20, 2006
Question

cf if is 'xxx' test for 20 of these

  • December 20, 2006
  • 5 replies
  • 927 views
I need to check the field "vendor_name" in a CFIF. I have no problem checking for one instance of the vendor_name, but.....

The same vendor_name has been entered into the database in 81 different ways, so I need to check for all 81.

When I use CFIF, do I need to use elseif......or can I use an 'OR', or is there some function that can handle this.

Thanks for all your help and Merry Christmas,
Wendy
    This topic has been closed for replies.

    5 replies

    Participating Frequently
    December 21, 2006
    Can't you break down the vendor name.

    e.g if the vendor name was Crossbeam Systems, Inc.

    and you had people adding

    Crossbeam Systems, Inc.
    Crossbeam Systems Inc
    Crossbeam Systems
    Crossbeam
    Crossbeam Sys. Inc.
    Cross beam Sys. Inc.

    Etc

    Couldn’t you do a CFIF to look for the Unique parts?

    <cfif findnocase(vendor_name,'cross') and findnocase(vendor_name,'beam')>

    There has to be some thing that links the names.
    Inspiring
    December 20, 2006
    The ListContains() solution is probably the best solution, but you could also look into using a <cfswitch>/<cfcase> statement if you are processing multiple vendors who all have different name variations.

    <cfswitch expression="#vendorName#">
    <cfcase value="foo,fooo,foo1">
    do something
    </cfcase>
    <cfcase value="boo,booo,boo2">
    do something else
    </cfcase>
    <cfdefaultcase>
    you could put code here to id entries that don't match any of your "known" variations
    </cfdefaultcase>
    </cfswitch>

    Hope that helps!
    Seyfert5Author
    Known Participant
    December 20, 2006
    81 itterations of a vendor name, yes. The vendor_names are sent to our database from every 261 different entities. The majority (70%) use one vendor name. We'll probably set a cut-off at (.5%), but I work for a very detailed man who likes everything accounted for.

    Anyway, thanks for your help.
    Inspiring
    December 21, 2006
    quote:

    Originally posted by: Seyfert5
    81 itterations of a vendor name, yes. The vendor_names are sent to our database from every 261 different entities. The majority (70%) use one vendor name. We'll probably set a cut-off at (.5%), but I work for a very detailed man who likes everything accounted for.

    Anyway, thanks for your help.

    If it's that predictable, why don't you just fix the data?
    Inspiring
    December 20, 2006
    When I use CFIF, do I need to use elseif......or can I use an 'OR', or
    is there some function that can handle this.


    Yes and yes and probably yes.

    You could use elseif's or OR clauses but this may work and should be
    less code then either of those methods.

    <cfset listofVenderVariants =
    "A,List,Of,All,The,Ways,The,Vender's,Name,Is,Spelled")>
    <cfset vender="Is">

    <cfif listContains(listOfVenderVariants,vender)>
    Inspiring
    December 21, 2006
    quote:

    Originally posted by: Newsgroup User
    When I use CFIF, do I need to use elseif......or can I use an 'OR', or
    is there some function that can handle this.
    Yes and yes and probably yes.
    You could use elseif's or OR clauses but this may work and should be
    less code then either of those methods.
    <cfset listofVenderVariants =
    "A,List,Of,All,The,Ways,The,Vender's,Name,Is,Spelled")>
    <cfset vender="Is">

    <cfif listContains(listOfVenderVariants,vender)>


    Good start, not so good on the finish
    <cfquery>
    select fields from tables
    where vendor in ( <cfqueryparam list="yes" etc )

    December 20, 2006
    wait...

    there are 81 different variations of a particular vendorname? seriously?

    how's that happen?

    yes, you could do an OR inside of a <cfif> a la

    <cfif (vendorName iS "foo") OR (vendorName IS "fooo") OR (vendorName IS "foo1") ...

    but I'd seriously look at nipping this in the bud and see if there's a way to rearchitect your system to prevent 'n' number of ways to represent a single vendor name.