473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Help with the IN() function

Hello I am working on a query where I am trying to SELECT a record using the IN() function:

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="getAddresses" datasource="#application.datasource#">
  2.     SELECT ID, COMP_NAME, ADDRESS1_1, CITY1, STATE1, ZIP1, PHONE1_1, FAX1_1, CATEGORY
  3.     FROM Vendors
  4.     WHERE #id# IN (CATEGORY)
  5.     ORDER BY COMP_NAME
  6. </cfquery>
id is a cfparam passed in on the url and CATEGORY is a varchar.

I am getting the following error:

Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Syntax error converting the varchar value '1,2,9' to a column of data type int.

Any help would be appreciated, I have tried everything!
Sep 7 '07 #1
3 1312
hariharanmca
1,977 1GB
Hello I am working on a query where I am trying to SELECT a record using the IN() function:

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="getAddresses" datasource="#application.datasource#">
  2.     SELECT ID, COMP_NAME, ADDRESS1_1, CITY1, STATE1, ZIP1, PHONE1_1, FAX1_1, CATEGORY
  3.     FROM Vendors
  4.     WHERE #id# IN (CATEGORY)
  5.     ORDER BY COMP_NAME
  6. </cfquery>
id is a cfparam passed in on the url and CATEGORY is a varchar.

I am getting the following error:

Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Syntax error converting the varchar value '1,2,9' to a column of data type int.

Any help would be appreciated, I have tried everything!
In() function should also contain select query
like

Expand|Select|Wrap|Line Numbers
  1. SELECT ID, COMP_NAME, ADDRESS1_1, CITY1, STATE1, ZIP1, PHONE1_1, FAX1_1, CATEGORY
  2.     FROM Vendors
  3.     WHERE #id# IN (Select Id_Category from CATEGORY)
  4.     ORDER BY COMP_NAME
Sep 7 '07 #2
Hello I am working on a query where I am trying to SELECT a record using the IN() function:

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="getAddresses" datasource="#application.datasource#">
  2.     SELECT ID, COMP_NAME, ADDRESS1_1, CITY1, STATE1, ZIP1, PHONE1_1, FAX1_1, CATEGORY
  3.     FROM Vendors
  4.     WHERE #id# IN (CATEGORY)
  5.     ORDER BY COMP_NAME
  6. </cfquery>
id is a cfparam passed in on the url and CATEGORY is a varchar.
I guess you're using ColdFusion? (the cf... and MacroMedia hint to that)
I don't have any experience or knowledge of CF, but #id# (probably an integer?) will never be part of a varchar field CATEGORY. The types just won't match.
And why check if the #id# is part of the CATEGORY field in the same record? Doesn't sound logical or useful to me...
Sep 7 '07 #3
Dont you mean
WHERE CATEGORY IN (#id#)

Hope that helps!
Feb 28 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: xuatla | last post by:
Hi, I have the following code for function pointer. compiling is ok. Can you help me to check whether it's a good way to implement as: class CA { ..... private: void f1( double ) ;
1
by: Rob | last post by:
Hi everyone, I'm having some big JS problems - my function is making my html code vanish, and I need help! Here's the code, try it for yourself. You'll notice that when you click either links...
5
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig ...
3
by: mikekimhome | last post by:
I am trying to capture a whole function definition from a file. I have read the contents of the file into a string variable and tried a regex to extract the function definition. Good thing is I...
4
by: Stef Mientki | last post by:
I'm making special versions of existing functions, and now I want the help-text of the newly created function to exists of 1. an extra line from my new function 2. all the help text from the old...
19
by: yxq | last post by:
Hello, I want to get the string resource from DLL file, the code work well for Vista x86, but it will not work on Vista x64, why? can anyone help to view the code below? thank you very much. ...
1
by: Bob | last post by:
Hi, Hope you can help me with this one. I'm at my wits end. I'm trying to create an intelligent edit-box like the excellent "Customer" one at the URL: ...
1
by: Lacreme | last post by:
My taxes do not want to calculate. I have tried sub precedures, functions, loops, select cases, and if/else structures. Im out of things to try. HELP.... Public Class Form1 Sub...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.