Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: UPDATE pytanie
Forum PHP.pl > Forum > Bazy danych > MySQL
dizor
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
maly_swd
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...

mooschka
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

To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.