Ok, so this is not exactly a scripting question...
I need the correct syntax for using UPDATE in a SQL statement where there are several fields (more than 10) that need to be updated with several values.
Update table_name set field1, field2, field3......field10 = value1, value2, value3....value10
I only have examples of updating a single field with a single variable.
SQL 'update' syntax
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Usually:
UPDATE table_name SET field1=value1, field2=value2, field3=value3 WHERE etc ....
UPDATE table_name SET field1=value1, field2=value2, field3=value3 WHERE etc ....
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
ok, here's the mess I've made so far....(it's copied from code that actually works, then modified...)
SQLString = _
"Update [PrintSource] set " + _
"[NMFC4] = '" & NC4 & "', [NCDesc4] = '" & NCDesc4 & "', [Class4] = '" & Class4 & "' + _
"[NMFC5] = " & NC5 & ", [NCDesc5] = " & NCDesc5 & ", [Class4] = " & Class5 & + _
"[NMFC6] = " & NC6 & ", [NCDesc6] = " & NCDesc6 & ", [Class4] = " & Class6 & + _
"[NMFC7] = " & NC7 & ", [NCDesc7] = " & NCDesc7 & ", [Class4] = " & Class7 & + _
"[NMFC8] = " & NC8 & ", [NCDesc8] = " & NCDesc8 & ", [Class4] = " & Class8 & + _
"[NMFC9] = " & NC9 & ", [NCDesc9] = " & NCDesc9 & ", [Class4] = " & Class9 & + _
"[NMFC10] = " & NC10 & ", [NCDesc10] = " & NCDesc10 & ", [Class4] = " & Class10
I am able to pass most of what I need to a function which creates the Access record and inserts about half the data, then I need to call another function to fill in the remainder of fields because I can only pass 24 parameters to the function.
SQLString = _
"Update [PrintSource] set " + _
"[NMFC4] = '" & NC4 & "', [NCDesc4] = '" & NCDesc4 & "', [Class4] = '" & Class4 & "' + _
"[NMFC5] = " & NC5 & ", [NCDesc5] = " & NCDesc5 & ", [Class4] = " & Class5 & + _
"[NMFC6] = " & NC6 & ", [NCDesc6] = " & NCDesc6 & ", [Class4] = " & Class6 & + _
"[NMFC7] = " & NC7 & ", [NCDesc7] = " & NCDesc7 & ", [Class4] = " & Class7 & + _
"[NMFC8] = " & NC8 & ", [NCDesc8] = " & NCDesc8 & ", [Class4] = " & Class8 & + _
"[NMFC9] = " & NC9 & ", [NCDesc9] = " & NCDesc9 & ", [Class4] = " & Class9 & + _
"[NMFC10] = " & NC10 & ", [NCDesc10] = " & NCDesc10 & ", [Class4] = " & Class10
I am able to pass most of what I need to a function which creates the Access record and inserts about half the data, then I need to call another function to fill in the remainder of fields because I can only pass 24 parameters to the function.