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
Solved

Need help with a SQL query error: probably me being stupid

Posted on 2007-03-27
4
155 Views
Last Modified: 2013-12-24
Hello All,

      I apologize in advance if this is really dumb; but coldfusion is giving me an error when i try to run the following delete query:

                              DELETE FROM FWjobs
                        WHERE title IN '#form.jobs#'
                        AND subcatText IN '#form.subcategories#'
                        AND catID IN '#form.categories#'
       
All the error says is incorrect syntax.  The stack trace shows the statement was evaluated at runtime as the following:

                               DELETE FROM FWjobs
                               WHERE title IN 'Delivery Person,Packer Person'
                               AND subcatText IN 'Delivery,Shipper'
                               AND catID IN '2,3'

Which looks correct to me; am I doing something stupid?

Thank you.
0
Comment
Question by:andrewaiello
  • 2
  • 2
4 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 125 total points
ID: 18801948
should look like this:
DELETE FROM FWjobs
WHERE title IN ('Delivery Person','Packer Person')
AND subcatText IN ('Delivery','Shipper')
AND catID IN (2,3)

ziolko.
0
 
LVL 1

Author Comment

by:andrewaiello
ID: 18802477
so the parentheses are missing.... those lists are coming in from the forms multiple selection list box...how can i change that?
0
 
LVL 1

Author Comment

by:andrewaiello
ID: 18802486
and also; the error only flagged on the last line of that query; if the parenthesis where the error..wouldn't the previous lines have been flagged?
0
 
LVL 21

Expert Comment

by:ziolko
ID: 18806423
error is only on last line (AND catID IN '2,3') because catId is of type int while '2,3' is treated as string.
theres no error in: AND subcatText IN 'Delivery,Shipper' because subcatText and 'Delivery,Shipper' are same type, but in this form 'Delivery, Shipper' will be treated as set containing just one string that is: 'Delivery,Shipper' and ('Delivery', 'Shipper') is set containg two strings

ziolko.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

856 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