Autor Beitrag
shil
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 143

Windows Xp
C#
BeitragVerfasst: Di 13.02.07 14:08 
hallo. ich habe da mal eine frage bezüglich der genauen syntax des sql statments update.
und zwar:
man kann ja mit select mehrere dinge aus einer datenbank auslesen.
ausblenden SQL-Anweisung
1:
SELECT name,plz,datum FROM person WHERE irgendwas = 'richtig'					


so, meine frage ist nun:
ich habe mehrer update befehle
ausblenden SQL-Anweisung
1:
UPDATE person SET name = 'neu' WHERE irgendwas = 'alt'					

und
ausblenden SQL-Anweisung
1:
UPDATE firma SET umsatz = '0,00' WHERE id = '0'					


Ich möchte diese 2 update statments ablaufen lasse.
Nur in meinem Programm will ich keine 2 odbccommands erstellen/ austauschen.
daher frage ich mich, ob es mit update die gleich möglichkeit wie bei select gibt.

mfg shil
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6386
Erhaltene Danke: 146

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 13.02.07 14:15 
Im Prinzip ja, allerdings nicht mit Deinem Beispielen. Du hast beim Select die selbe Where-Bedingung. Beim Update zwei verschiedene.

Für die Syntax:
sql.1keydata.com/de/sql-update.php
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 13.02.07 14:16 
user profile iconshil hat folgendes geschrieben:
Nur in meinem Programm will ich keine 2 odbccommands erstellen/ austauschen.
daher frage ich mich, ob es mit update die gleich möglichkeit wie bei select gibt.

Die gleiche Möglichkeit was zu machen? Ein Select ist schließlich was anderes als ein Update. Oder willst Du die beiden Updates zusammenfassen?
shil Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 143

Windows Xp
C#
BeitragVerfasst: Di 13.02.07 14:56 
also ich habe x Tabllen in denen ich werte ändern muss.
die where bedingung hat nur eine bedingung (eine id)

es sind insgesamt 4 tabellen in denen ich eine id mit dem gleichen namen änderen muss.

ausblenden SQL-Anweisung
1:
2:
3:
4:
UPDATE person SET person_id = {0} WHERE person_id = {1}
UPDATE appointment SET person_id = {0} WHERE person_id = {1}
UPDATE sale SET person_id = {0} WHERE person_id = {1}
UPDATE selectionmember SET person_id = {0} WHERE person_id = {1}

( was in den {} steht wird du string.format() ersetzt)
so sehen meine statments in etwa aus und genau diese will ich zusammenführen.
Kha
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3803
Erhaltene Danke: 176

Arch Linux
Python, C, C++ (vim)
BeitragVerfasst: Di 13.02.07 20:43 
In meinen Ohren schreit das nach einer Stored Procedure ;) .