Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Inser z podzapytaniem wielowierszowym
Avatarus
post
Post #1





Grupa: Zarejestrowani
Postów: 304
Pomógł: 0
Dołączył: 12.12.2006
Skąd: Pszów

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


witam
mam 2 tabele:
  1. CREATE TABLE IF NOT EXISTS `handlarze` (
  2. `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `typ` tinyint(3) UNSIGNED NOT NULL,
  4. `id_gracza` bigint(20) UNSIGNED NOT NULL,
  5. `czas` bigint(20) UNSIGNED NOT NULL,
  6. `slot_1` bigint(20) UNSIGNED NOT NULL,
  7. `slot_2` bigint(20) UNSIGNED NOT NULL,
  8. `slot_3` bigint(20) UNSIGNED NOT NULL,
  9. `slot_4` bigint(20) UNSIGNED NOT NULL,
  10. `slot_5` bigint(20) UNSIGNED NOT NULL,
  11. `slot_6` bigint(20) UNSIGNED NOT NULL,
  12. `slot_7` bigint(20) UNSIGNED NOT NULL,
  13. `slot_8` bigint(20) UNSIGNED NOT NULL,
  14. `slot_9` bigint(20) UNSIGNED NOT NULL,
  15. `slot_10` bigint(20) UNSIGNED NOT NULL,
  16. PRIMARY KEY (`id`)
  17. ) ENGINE=MyISAM DEFAULT CHARSET=latin2 AUTO_INCREMENT=3 ;


Druga tabela zawiera id,nazwa.
Potrzebuje zrobic zapytanie która do 1 tabeli doda id,typ,id_gracz,czas (te dane są z poziomu php generowane) a na dodatek dodaj w pozostałe 10 pól wynik podzapytania:
  1. SELECT id FROM przedmioty ORDER BY rand() LIMIT 10


Próbowałem to zrobić tak:
  1. INSERT INTO handlarze (id,typ,id_gracza,czas,slot_1,slot_2,slot_3,slot_4,slot_5,slot_6,slot_7,slot_8,slot_9,slot_10) VALUES(NULL,1,1,1111111,(SELECT id FROM przedmioty ORDER BY rand() LIMIT 10))

ale nie działa
Macie jakieś sugestie?


--------------------
Go to the top of the page
+Quote Post

Posty w temacie


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 Aktualny czas: 19.08.2025 - 09:01