Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL syntax error... using WHERE userID IN

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
Can I not use "IN" when im inserting? If not how can insert records with checkbox values like : 1, 3, 4, etc
------------------------

Microsoft OLE DB Provider for ODBC Drivers error '80040e09'

[MySQL][ODBC 3.51 Driver][mysqld-3.23.51-max-debug]You have an error in your SQL syntax near 'WHERE userID IN (1)' at line 1

----------------------------------------



Code:
If Request.Form(&quot;save&quot;) = &quot;true&quot; AND Request.Form(&quot;payed&quot;) <> &quot;&quot; then

  '# Create Connection & Recordset
  Set conn = createobject(&quot;ADODB.Connection&quot;)
  set supdate = Server.CreateObject(&quot;ADODB.RecordSet&quot;)
	
  '# Run open connection function
  Database(&quot;open&quot;)
				
  '# Make sql statement
  SQLupdate = &quot;INSERT INTO users (uPayed) VALUES ('&quot; & &quot;y&quot; & &quot;') WHERE userID IN (&quot; & Request.Form(&quot;payed&quot;) & &quot;)&quot;
				

  set supdate = conn.Execute(SQLupdate)
						
  Database(&quot;close&quot;)
						
End If
www.vzio.com
ASP WEB DEVELOPMENT



 
It aoppears to me that you need to update not INSERT, insertion is for new record creation only, update will update existing records(if your db supports it).
Therefore you cannot use a WHERE when inserting because you cannot insert a record into a table WHERE anything is true about that record, because it does not exist yet.
If the record already exists try:
&quot;UPDATE user SET uPayed = '&quot; & y & &quot;' WHERE userID IN (&quot; & Request.Form(&quot;payed&quot;) & &quot;)&quot;

This may not work with some versions of MySQL, UPDATE is only supported in certain versions (gotta love open source)
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Thanks, I don't know why I didnt catch that.. www.vzio.com
ASP WEB DEVELOPMENT



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top