Subject: Update multiple fields.
Posted By: slgknjn Post Date: 2/14/2004 11:54:51 AM

I have the need for updating multiple fields in a record.
The table name is kontingent. My sql statement look like this.

MySql = "UPDATE Kontingent SET(Jan, Feb, Mar, Apr, Maj, Jun, Jul, Aug, Sep, Okt, Nov, Dec) = (2,2,1,1,1,1,1,2,2,2,2,2) WHERE MemID =18"

I am updating another table before this one and it works fine,

but when I excecute the statement.
set objRS = objDC.Execute(MySql)

I get the page is not available. Can anyone see what is wrong in my sql string. Thanks in advance.



Reply By: Jonax Reply Date: 2/14/2004 12:05:20 PM
You need to pass the values 'one by one', like this:

UPDATE Kontingent SET Jan = 2, Feb = 2, Mar = 1 ...

Håber det hjælper...

Reply By: slgknjn Reply Date: 2/14/2004 12:26:18 PM
Hi Jonax
Thank for your reply
I was afraid that this might be the problem, but others tell me that the following syntaks should be possible.
"
It is also possible to UPDATE multiple columns at the same time. The syntax in this case would look like the following:

UPDATE TABLE "table_name"
SET ("column_1", "column_2") = ([new value 1], [new value 2])
WHERE {condition}
"
Ha en forsat god dag.


Reply By: Jonax Reply Date: 2/14/2004 2:06:57 PM
Hi again,

I have never seen that syntax used - have a look here: http://www.mysql.com/doc/en/UPDATE.html

Reply By: slgknjn Reply Date: 2/14/2004 2:22:00 PM
Hi Jonax

Your link basicly shows your first idea. My logical sence tell me that it can't be true that one have to send multiple commands to update one record. My first suggestion came from here. http://www.1keydata.com/sql/sqlupdate.html
They can of course be wrong, but it make sence.
Cheers
Karsten


Reply By: Jonax Reply Date: 2/14/2004 2:55:24 PM
I shan't say they're wrong - but as previously mentioned - it's not a syntax that I reckognize. The syntax I'm suggesting doesn't mean that you have to send multiple commands - you can update many fields using one statement...

UPDATE Kontingent SET Jan = 2, Feb = 2, Mar = 1 WHERE MemID = 18

By the way - what database are you using, and are all of your fields of type INT?


Reply By: slgknjn Reply Date: 2/15/2004 9:26:23 AM
Hi Jonax
I got it working after some rewriting of my VB. Thanks for your help.
Cheers.



Go to topic 9828

Return to index page 948
Return to index page 947
Return to index page 946
Return to index page 945
Return to index page 944
Return to index page 943
Return to index page 942
Return to index page 941
Return to index page 940
Return to index page 939