?
Solved

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

Posted on 2007-03-27
4
Medium Priority
?
164 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 375 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

Industry Leaders: 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

Ready to get certified? Check out some courses that help you prepare for third-party exams.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

850 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