Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6602025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:49:41+00:00 2026-05-25T18:49:41+00:00

I have a query similar to this: SELECT itemID FROM itemTable WHERE itemID LIKE

  • 0

I have a query similar to this:

SELECT itemID
FROM itemTable
WHERE itemID LIKE ‘%123%’

itemTable is of type INT. This query works just fine by itself, as it would select ‘12345’ and ‘0912398’ and so on…

The problem occurs when I try to use

Let’s say var searchValue = 123

If I try: <cfqueryparam cfsqltype='cf_sql_integer' value="'%#searchValue#%'" >

I get *Invalid data ‘123’ for CFSQLTYPE CF_SQL_INTEGER.*

If I try: <cfqueryparam cfsqltype='cf_sql_varchar' value="'%#searchValue#%'" >

I get java.lang.Integer cannot be cast to java.lang.String

I’ve tried using CAST in my SQL, and also using toString(searchValue) in various places, but I always end up with one of the error messages above. Is there any way to search and integer table using CFQUERYPARAM?

EDIT: Below is the actual code I am trying to use…

CFSCRIPT Code:

var searchValue=123;
searchFilterQuery(qry=qItemResults, field="itemID", value=searchValue,cfsqltype="cf_sql_varchar");

CFC Function:

<!--- FILTER A QUERY WITH SEARCH TERM --->
<cffunction name="searchFilterQuery" access="public" returntype="query" hint="Filters a query by the given value" output="false">
    <!--- ************************************************************* --->
    <cfargument name="qry"          type="query"    required="true" hint="Query to filter">
    <cfargument name="field"        type="string"   required="true" hint="Field to filter on">
    <cfargument name="value"        type="string"   required="true" hint="Value to filter on">
    <cfargument name="cfsqltype"    type="string"   required="false" default="cf_sql_varchar" hint="The cf sql type of the value.">
    <!--- ************************************************************* --->
    <cfset var qryNew = QueryNew("")>
    <cfquery name="qryNew" dbtype="query">
        SELECT *
            FROM arguments.qry
            WHERE #trim(arguments.field)# LIKE <cfqueryparam cfsqltype="#trim(arguments.cfsqltype)#" value="#trim(arguments.value)#">
    </cfquery>
    <cfreturn qryNew>
</cffunction>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:49:41+00:00Added an answer on May 25, 2026 at 6:49 pm

    You need to do this, I reckon:

    • remove the quotes as people have said

    • use a VARCHAR param, not an INTEGER, as the % symbols make the value you’re passing not an INTEGER

    • CAST the integer column as a VARCHAR on the DB side of things. The DB could possibly do this automatically for you, but I reckon it’s better to be explicit about these things.

      SELECT itemID
      FROM itemTable
      WHERE CAST(itemId AS VARCHAR) LIKE <cfqueryparam cfsqltype=’cf_sql_varchar’ value=”%#searchValue#%”>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have query like this : SELECT EXTRACT(MONTH FROM d.mydate) AS synmonth, SUM(apcp) AS
I currently have a query similar to: SELECT users.fname, users.lname, sales.date FROM users LEFT
We have a Union Query. Here's a basic (similar) example: SELECT a.Name, b.Info FROM
I have this query select item_name from some_table sometimes item_name is a 'sometext' value
I have this query: SELECT p.text,se.name,s.sub_name,SUM((p.volume / (SELECT SUM(p.volume) FROM phrase p WHERE p.volume
I have a query that looks something like this: select xmlelement(rootNode, (case when XH.ID
I have a query similar to the following, select * from T1 where abc
I have query similar to this: DECLARE @value decimal(8,0) = 1 SELECT (CAST @value
I have this query: SELECT `country` FROM `geoip_base` WHERE 1840344811 BETWEEN `start` AND `stop`
I have a query similar to the following: SELECT users.id FROM users LEFT JOIN

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.