Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> UPDATE pytanie
dizor
post 4.11.2009, 11:08:43
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 17.09.2009

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


Jak w MySQL wykonać coś takiego:

update data set gallery = 1 where gallery = 2 and category = 4;
update data set gallery = 2 where gallery = 1 and category = 4;

Chcę zamienić wszystkie gallery = 1 na 2 , a potem 2 na 1

id:1, gallery: 1
id:2, gallery: 1
id:3, gallery: 2
id:4, gallery: 2

na

id:1, gallery: 2
id:2, gallery: 2
id:3, gallery: 1
id:4, gallery: 1
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
maly_swd
post 4.11.2009, 11:26:24
Post #2





Grupa: Zarejestrowani
Postów: 744
Pomógł: 118
Dołączył: 14.02.2009
Skąd: poziome

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


Musisz tzw zbuforowac sobie dane:)

update data set gallery = -1 where gallery = 2 and category = 4;
update data set gallery = 2 where gallery = 1 and category = 4;
update data set gallery = 2 where gallery = -1 and category = 4;

warunek pole galery musi ze znakiem:) czyli nie unsig...



--------------------
śmieszne obrazki
Kryzys: Ser jem spleśniały, wino piję stare i samochód mam bez dachu..
Go to the top of the page
+Quote Post
mooschka
post 5.11.2009, 08:51:03
Post #3





Grupa: Zarejestrowani
Postów: 8
Pomógł: 1
Dołączył: 31.10.2009

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


Cytat(dizor @ 4.11.2009, 11:08:43 ) *
Jak w MySQL wykonać coś takiego:

update data set gallery = 1 where gallery = 2 and category = 4;
update data set gallery = 2 where gallery = 1 and category = 4;


A ja proponuję coś takiego:
  1. UPDATE DATA SET gallery=3-gallery WHERE category=4

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: 14.08.2025 - 04:30