Autor | Zpráva | ||
---|---|---|---|
E Profil * |
#1 · Zasláno: 8. 12. 2011, 21:46:47
Dobrý deň chcem sa spýtať ako dosiahnem to že ak mám tabulku a v nej
id, username, klientid a mám napr. jeden riadok vyplnené všetky hodnoty a v druhom nemam vyplnené username ale klientid je rovnaké ako s prvým záznamom ako dosiahnem aby mi ho username updatovalo tak aby bolo zhodné s prvým záznamom? |
||
Petr Ká Profil |
#2 · Zasláno: 9. 12. 2011, 00:49:06
ahoj
google => update where (select ... ) |
||
E Profil * |
#3 · Zasláno: 9. 12. 2011, 09:21:01
mysql_query("update sl_internet set username=(select username from (select username from sl_internet where length(username) > 0 and klientid=klientid) as subselctTable) where klientid=klientid;"); nieako mi to nefunguje kde robím chybu? |
||
Kajman_ Profil * |
#4 · Zasláno: 9. 12. 2011, 10:42:31
Možná takto nějak
update sl_internet ch join (select klientid, min(username) username from sl_internet group by klientid where nullif(username,'') is not null) v on ch.klientid = v.klientid set ch.username = v.username where nullif(ch.username,'') is null Ale uniká mi smysl. Normální je mít v takové tabulce jen klientid. Username se dáva do jiné a jen se přilinkuje, pokud je na výstupu potřeba. |
||
E Profil * |
#5 · Zasláno: 9. 12. 2011, 12:54:09
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where nullif(username,'') is not null) v on ch.klientid = v.klientid set ' at line 5 prečo táto chyba? |
||
Kajman_ Profil * |
#6 · Zasláno: 9. 12. 2011, 14:19:02
Přehodil jsem group by a where, opravte si pořadí.
|
||
E Profil * |
#7 · Zasláno: 9. 12. 2011, 14:26:24
Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group by klientid on ch.klientid = v.klientid set ch.username = v.user' at line 5 opať |
||
panther Profil |
#8 · Zasláno: 9. 12. 2011, 14:52:49
E:
tipnu si, že jsi vzal celý Kajmanův pátý řádek a prohodil ho za čtvrtý. To nejde, musíš taky trochu přemýšlet, konkrétně, k čemu patří ta koncová závorka a alias v .
|
||
E Profil * |
#9 · Zasláno: 9. 12. 2011, 14:57:10
dobre si tipol ,, no dal som to v naspať do 5 ale opať
Every derived table must have its own alias |
||
E Profil * |
#10 · Zasláno: 9. 12. 2011, 15:14:23
Ďakujem veľmi pekne (neporečital som si to poriadne :) )
už to funguje tu to je ak by niekedy nikto to potreboval: mysql_query("update sl_internet ch join (select klientid, min(username) username from sl_internet where nullif(username,'') is not null group by klientid) v on ch.klientid = v.klientid set ch.username = v.username where nullif(ch.username,'') is null")or die('Query failed: ' . mysql_error()); |
||
Časová prodleva: 12 let
|
0