Solved

cfquery and LIKE problem

Posted on 2008-10-19
9
437 Views
Last Modified: 2013-12-24
Hello experts.
I have a search page with a search form where i can check more than 1 one checkboxes with the same name but different values.

What like must be the query in the result page to get the items with Kat_ID =7 and items with Kat_ID =2
and items with Kat_ID =4 if i would check the three boxes.
The test query i have don't work:(i have no results)
<cfquery name="artikel" datasource="#dsn#">
SELECT Kat_ID
 WHERE
<cfif isdefined("Url.S_Kat_ID") AND Url.S_Kat_ID NEQ "">     
   Kat_ID LIKE <cfqueryparam value="#URL.S_Kat_ID#" cfsqltype="cf_sql_numeric">
      </cfif>
</cfquery>        
<input name="S_Kat_ID" type="checkbox" id="S_Kat_IDvan" value="7" />
<input name="S_Kat_ID" type="checkbox"id="S_Kat_IDPU" value="2" />
<input name="S_Kat_IDPU" type="checkbox"id="S_Kat_IDKB" value="4" />

Open in new window

0
Comment
Question by:Panos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 9

Expert Comment

by:Andrew Maurer
ID: 22752579
Couple things..

I see your three values.. one is not the same name as the other two.. S_Kat_IDPU

Also.. you are checking if a variable is defined and whats its value is... if the variable was not defined, your if statement would throw a error.

AND.. use the IN operator

<cfif isdefined("Url.S_Kat_ID")>
    <cfif Url.S_Kat_ID NEQ "">      
        Kat_ID IN (<cfqueryparam value="#URL.S_Kat_ID#" cfsqltype="cf_sql_integer" list="yes">
    </cfif>
</cfif> 

Open in new window

0
 
LVL 9

Accepted Solution

by:
Andrew Maurer earned 500 total points
ID: 22752584
correction... missing right paren )
<cfif isdefined("Url.S_Kat_ID")>
    <cfif Url.S_Kat_ID NEQ "">      
        Kat_ID IN (<cfqueryparam value="#URL.S_Kat_ID#" cfsqltype="cf_sql_integer" list="yes">)
    </cfif>
</cfif>

Open in new window

0
 
LVL 2

Author Comment

by:Panos
ID: 22752848
Hi again Zadoc.
The IN operator is not working and i have error.
0
Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

 
LVL 9

Expert Comment

by:Andrew Maurer
ID: 22752858
what is the error?
0
 
LVL 2

Author Comment

by:Panos
ID: 22752926
[Macromedia][SQLServer JDBC Driver][SQLServer]Line 34: Incorrect syntax near '@P2'.


0
 
LVL 2

Author Comment

by:Panos
ID: 22752932
The error occurred in C:\Inetpub\wwwroot\car&home7\resultscheck.cfm: line 107

105 : <cfif isDefined ("Url.S_Mobile_Sub_ID")>
106 :     <cfif   Url.S_Mobile_Sub_ID>  
107 :  AND  a.Mobile_Sub_ID = <cfqueryparam value="#URL.S_Mobile_Sub_ID#" cfsqltype="cf_sql_numeric">
108 :       </cfif>
109 :    </cfif>
0
 
LVL 9

Expert Comment

by:Andrew Maurer
ID: 22752948
for your second comment.. you haVe this
<cfif   Url.S_Mobile_Sub_ID>

maybe...
<cfif   Url.S_Mobile_Sub_ID NEQ "">
0
 
LVL 2

Author Comment

by:Panos
ID: 22752969
Stop looking at.
I did the mistace.I forgot the () in the last code you did post in the other question.
Thank you very much
0
 
LVL 2

Author Closing Comment

by:Panos
ID: 31507596
Thank you again for your help.
I will be back.
I hope you will help me again
regards
panos
0

Featured Post

Don't Miss ATEN at InfoComm 2017!

Visit booth #2167 to see the  new ATEN VM3200 32 x 32 Modular Matrix Switch. Other highlights include the VE8950 4K HDMI Over IP Extender, VS1912 12-Port DP Video Wall Media Player  and VK2100 ATEN Control System. Register now with Free Pass Code ATEN288!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question