Zadejte hledaný výraz...

Jak vytvořit insert k níže uvedenému selectu?

Flavo
verified
rating uzivatele
(1 hodnocení)
29. 10. 2019 14:41:31
Dobrý den, můžete mi prosím poradit, jak vytvořit insert k níže uvedenému selectu? Nedaří se mi to nijak zformulovat :/
????Insert into ps_stock????
Select ps_feature_value_lang.value As Physical_quantity, ps_product.reference, ps_product.id_product, ps_warehouse.id_warehouse From ps_feature_product Inner Join ps_feature_value_lang On ps_feature_product.id_feature_value = ps_feature_value_lang.id_feature_value Inner Join ps_product On ps_product.id_product = ps_feature_product.id_product Inner Join ps_feature_lang On ps_feature_product.id_feature = ps_feature_lang.id_feature Inner Join ps_warehouse On ps_warehouse.name = ps_feature_lang.name Where ps_feature_lang.name = 'PI'
Tabulka ps_stock:
CREATE TABLE ps_stock (
id_stock int(11) unsigned NOT NULL AUTO_INCREMENT,
id_warehouse int(11) unsigned NOT NULL,
id_product int(11) unsigned NOT NULL,
id_product_attribute int(11) unsigned NOT NULL,
reference varchar(64) NOT NULL,
ean13 varchar(13) DEFAULT NULL,
isbn varchar(32) DEFAULT NULL,
upc varchar(12) DEFAULT NULL,
physical_quantity int(11) unsigned NOT NULL,
usable_quantity int(11) unsigned NOT NULL,
price_te decimal(20,6) DEFAULT '0.000000',
PRIMARY KEY (id_stock),
KEY id_warehouse (id_warehouse),
KEY id_product (id_product),
KEY id_product_attribute (id_product_attribute)
) ENGINE=MyISAM AUTO_INCREMENT=29 DEFAULT CHARSET=utf8
29. 10. 2019 14:41:31
https://webtrh.cz/diskuse/jak-vytvorit-insert-k-nize-uvedenemu-selectu#reply1421782
TomasX
verified
rating uzivatele
(4 hodnocení)
29. 10. 2019 15:50:19
prestashop neznám, předpokládám, že struktury jsou z něho. Z dat, která jsi poskytl vůbec není jasné jaké datové typy jsou v selectu a to nejspíš ti dělá problém.
Osobně bych zkusil si ze selectu vytvořit tabulku
a porovnat vytvořenou tabulkou s ps_stock, budou tam některé rozdíly.
Případně poskytni chybovou hlášku, kde bude také nejspíš napsané co děláš špatně.
29. 10. 2019 15:50:19
https://webtrh.cz/diskuse/jak-vytvorit-insert-k-nize-uvedenemu-selectu#reply1421781
takatom
verified
rating uzivatele
(2 hodnocení)
29. 10. 2019 15:54:23
usable_quantity má NOT NULL - buď povolte nebo nahraďte nulu v SELECTu
insert into ps_stock (physical_quantity, reference,id_product,id_warehause ,usable_quantity)
Select ps_feature_value_lang.value As Physical_quantity,
ps_product.reference,
ps_product.id_product,
ps_warehouse.id_warehouse,
0
From ps_feature_product
Inner Join ps_feature_value_lang On ps_feature_product.id_feature_value = ps_feature_value_lang.id_feature_value
Inner Join ps_product On ps_product.id_product = ps_feature_product.id_product
Inner Join ps_feature_lang On ps_feature_product.id_feature = ps_feature_lang.id_feature
Inner Join ps_warehouse On ps_warehouse.name = ps_feature_lang.name Where ps_feature_lang.name = 'PI'
29. 10. 2019 15:54:23
https://webtrh.cz/diskuse/jak-vytvorit-insert-k-nize-uvedenemu-selectu#reply1421780
Flavo
verified
rating uzivatele
(1 hodnocení)
30. 10. 2019 11:04:05
Děkuji za radu, pomohla :)
Někdo by řekl, že je to školácká chyba, jenže já školák nejsem - jen pouhopouhý samouk.
Ještě jednou děkuji, ušetřil jste mi hodně času.
Napsal takatom;1551400
usable_quantity má NOT NULL - buď povolte nebo nahraďte nulu v SELECTu
insert into ps_stock (physical_quantity, reference,id_product,id_warehause ,usable_quantity)
Select ps_feature_value_lang.value As Physical_quantity,
ps_product.reference,
ps_product.id_product,
ps_warehouse.id_warehouse,
0
From ps_feature_product
Inner Join ps_feature_value_lang On ps_feature_product.id_feature_value = ps_feature_value_lang.id_feature_value
Inner Join ps_product On ps_product.id_product = ps_feature_product.id_product
Inner Join ps_feature_lang On ps_feature_product.id_feature = ps_feature_lang.id_feature
Inner Join ps_warehouse On ps_warehouse.name = ps_feature_lang.name Where ps_feature_lang.name = 'PI'
30. 10. 2019 11:04:05
https://webtrh.cz/diskuse/jak-vytvorit-insert-k-nize-uvedenemu-selectu#reply1421779
Pro odpověď se přihlašte.
Přihlásit