House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / ColdFusion Newbie (CF-Newbie)

What's Wrong with My Query?

Author:
Renee Spadaro
03/12/2010 12:09 PM

Adam, You're trying to insert a record into a table where the PoemID exists.  If it's a new record, the ID doesn't exist. Are you trying to update a record?  If so, you need to use an UPDATE Statement. Update table Set ..... Where poemID = #url.id# Try that. Renee > The query from code: > > INSERT INTO table (poemID, rating, username) > VALUES (#url.id#, #form.rating#, '#session.username#') > WHERE poemID = #url.id# > > > Error details: > > Error Executing Database Query. > [Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near > the keyword 'WHERE'. > > The error occurred in [pathToFile]\poemOverview.cfm: line 75 > > 73 : INSERT INTO table (poemID, rating, username) > 74 : VALUES (#url.id#, #form.rating#, '#session.username#') > 75 : WHERE poemID = #url.id# > 76 : </cfquery> > 77 :    > > SQLSTATE     HY000 > SQL      INSERT INTO PoetryContest2010Ratings (poemID, rating, > username) VALUES (5, 4, 'adgparke') WHERE poemID = 5 > > > From the error, it looks like the values are being passed, but the > data isn't written to the table and the page errors. > > I've tried moving single quotes around the values being inserted to no > avail.  Any help is appreciated. > > Thanks in advance.


Search cf-newbie

February 11, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29