found the misktake! the whereclause must be: whereclause = {'where Date = ''1.1.'' and ID = ''1''' ; 'where Date = ''1.1.'' and ID = ''2'''};
Using sql update with multiple where conditions
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gerald Blumberg
le 2 Août 2016
Réponse apportée : Gerald Blumberg
le 3 Août 2016
Hello,
I am trying to use the update function to update my sql database. Even though I went to the documentation I still have trouble to update a table of the following structure:
Date........ID........Value1........ Value2
--------------------------------------
1.1............1...........5................7
1.1............2...........3................8
...
2.1............1...........9................12
2.1............2...........1............... 333
As you will recognize, "ID" as well as "Date" values occure more than ones and aren't unique. Only the combination of both is unique. Thats why I need multiple whereclause conditions!
Imagine I want to update the column "Value2" in the first 2 rows. How would I do that? I found some solutions using set and case but i want to update some thousends of data thats why hard coding the combination would be pretty uncool...
So far I have a valid connection "conn" and a cell ("cell2insert") which obtains a new value in each row; i.e. cell2insert = {1;2}; Additionally, I have a cell "whereclause" obtaining strings: whereclause = {'where Date = 1.1. and ID = 1' ; 'where Date = 1.1. and ID = 2'};
Using this, I try to apply "update": update(conn, aim , {'Value2'} , cell2insert , whereclause); (where aim is my database table)
I tryed to use a table instead of cell2insert but failed anyway...
Thanks in advance and regards, Gerald
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!