Solved

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

Posted on 2007-03-27
4
156 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
[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
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

733 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