Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Jednoczesny update wszystkich pol rekordu
yalus
post 7.02.2007, 12:06:53
Post #1





Grupa: Zarejestrowani
Postów: 281
Pomógł: 0
Dołączył: 8.07.2005
Skąd: EU

Ostrzeżenie: (0%)
-----


witam

czy jest mozliwe updejtowanie wszystkich pol jednego rekordu ktore sa null przy uzyciu jednego zapytania sql


rekord sklada sie z 35 pol ale tylko niektore pola sa null np:

pole1| pole2| pole3|
'abc' | null | 'abc' |
'null' | null | 'abc' |
'abc' | 'abc' | 'null' |
'abc' | null | 'abc' |

jak teraz skonstruowac zapytanie aby realizowalo cos takiego

update tabela set pole1='' where pole1 is null, set pole2='' where pole2 is null set pole3='' where pole3 is null


pozdrawiam

Ten post edytował yalus 7.02.2007, 13:24:13


--------------------
człowiek nie sznurek wszystko wytrzyma
Go to the top of the page
+Quote Post
defrag
post 7.02.2007, 13:19:25
Post #2





Grupa: Zarejestrowani
Postów: 82
Pomógł: 3
Dołączył: 15.01.2007

Ostrzeżenie: (10%)
X----


  1. UPDATE tabela SET kolumna = ' ' WHERE columna = NULL
Go to the top of the page
+Quote Post
yalus
post 7.02.2007, 13:27:10
Post #3





Grupa: Zarejestrowani
Postów: 281
Pomógł: 0
Dołączył: 8.07.2005
Skąd: EU

Ostrzeżenie: (0%)
-----


no tak a co jak ja bym chcial updajtowac inne pola tego samego rekordu

wedlug tej reguly

update tabela set pole1='' where pole1 is null, set pole2='' where pole2 is null set pole3='' where pole3 is null

Ten post edytował yalus 7.02.2007, 13:27:55


--------------------
człowiek nie sznurek wszystko wytrzyma
Go to the top of the page
+Quote Post
Vogel
post 7.02.2007, 13:34:55
Post #4





Grupa: Zarejestrowani
Postów: 402
Pomógł: 0
Dołączył: 20.01.2003

Ostrzeżenie: (0%)
-----


  1. UPDATE ... WHERE pole1=NULL OR pole2=NULL...


--------------------
Go to the top of the page
+Quote Post
yalus
post 7.02.2007, 14:19:36
Post #5





Grupa: Zarejestrowani
Postów: 281
Pomógł: 0
Dołączył: 8.07.2005
Skąd: EU

Ostrzeżenie: (0%)
-----


tak ale w takim przypadku

pole1| pole2| pole3|
'abc' | null | 'abc' |
'null' | null | 'abc' |
'abc' | 'abc' | 'null' |
'abc' | null | 'abc' |


to co napisales
  1. UPDATE tabela SET pole1='', pole2='', pole3='' WHERE pole1=NULL OR pole2=NULL

zaktualizuje caly rekord a mi chodzi tylko o te pola w ktorych jest null


--------------------
człowiek nie sznurek wszystko wytrzyma
Go to the top of the page
+Quote Post
nospor
post 7.02.2007, 14:26:00
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




  1. UPDATE tabela SET pole1=ifnull(pole1,''), pole2=ifnull(pole2,''), pole3=ifnull(pole3,'')


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

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
yalus
post 7.02.2007, 15:06:37
Post #7





Grupa: Zarejestrowani
Postów: 281
Pomógł: 0
Dołączył: 8.07.2005
Skąd: EU

Ostrzeżenie: (0%)
-----


thx


--------------------
człowiek nie sznurek wszystko wytrzyma
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 24.07.2025 - 21:25