cfqueryparam and wildcard select for search

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default cfqueryparam and wildcard select for search

    Quick Question.

    I am having some difficulty with this select statement for a search:

    SELECT * FROM table WHERE name like ''<cfqueryparam
    value="#form.txtCompanySearch#" cfsqltype="cf_sql_varchar">''%'"

    This statement always fails. What changes do I need to make to the syntax? I
    want to be able to have the user enter the first few characters, then append a
    wildcard to the variable using the cfqueryparam. I have tried different
    variations to escape the % symbol but nothing seems to work.

    IE: SELECT * FROM table WHERE name like 'abc%'

    Thanks for the help.

    runner ed Guest

  2. Similar Questions and Discussions

    1. Solution for the question: Select a single word in a text field after a search
      In Filemaker 6: Define a global field named "gSearched_word" to store word that you want to find. Make a script to enter in find mode as below:...
    2. wildcard in SELECT
      I have 96 fields named s1, s2, s3... s96 with hundreds of rows in a msSQL2000 db. I need to get the sum of the fields and was wondering if there is...
    3. wildcard search
      I have the following SQL that searches based on the exact input stored in a session variable If reqname <> '' Then strSQL = strSQL &amp;...
    4. Wildcard and DTS..?
      Hi all, I have a path in a DTS-package that looks like: sFilename = "d:\path\*.PMS" & Right(Year(Now()), 2) sFilename = DTSGlobalVariables ...
    5. Select a single word in a text field after a search
      in article PvMJa.17242$dP1.32589@newsc.telia.net, nisse@nisse.se at nisse@nisse.se wrote on 6/23/03 4:59 PM: If you're on the Mac sind, and...
  3. #2

    Default Re: cfqueryparam and wildcard select for search

    runner ed wrote:
    > Quick Question.
    >
    > I am having some difficulty with this select statement for a search:
    >
    > SELECT * FROM table WHERE name like ''<cfqueryparam
    > value="#form.txtCompanySearch#" cfsqltype="cf_sql_varchar">''%'"
    SELECT *
    FROM table
    WHERE name like <cfqueryparam value="#form.txtCompanySearch#%"
    cfsqltype="cf_sql_varchar">

    Jochem

    --
    Jochem van Dieten
    Team Macromedia Volunteer for ColdFusion, beer and fun.
    Jochem van Dieten - TMM Guest

  4. #3

    Default Re: cfqueryparam and wildcard select for search

    like so,
    SELECT * FROM table WHERE name like <cfqueryparam value="#form.txtCompanySearch#%" cfsqltype="cf_sql_varchar">

    Ken

    The ScareCrow Guest

  5. #4

    Default Re: cfqueryparam and wildcard select for search

    That worked. Thanks.
    runner ed Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139