我目前正在使用MySQL5.6。当我试图导入 .sql
文件和获取错误。
这就是 .sql
文件:
CREATE VIEW page_view
AS (SELECT DISTINCT
res.*,
res.`finalprice` as normalprice,
(CASE WHEN (res.pricesale <> 0) THEN 1 ELSE 0 END) AS is_on_sale,
(res.`pricecatalog` - res.`finalprice`) AS catelog_price_diff,
ROUND((100-((res.`finalprice` / res.`pricecatalog`)*100))) AS catelog_price_perc_diff
FROM (
SELECT DISTINCT
p.id,p.name,p.inner_id,p.sort,p.assigned_cat_id,p.assigned_manufacturer_id,
pt.page_id, pt.lang, pt.title, pt.su_title, pt.zap_title, pt.text, pt.textmobile, pt.url_id, pt.template, pt.menu_name, pt.page_title, pt.meta_description, pt.default_child_description, pt.default_text_for_child_manufacturer_products_list, pt.meta_keywords, pt.heads_meta, pt.no_index_no_follow, pt.show_stock_progress_bar, pt.menu_display_primery, pt.menu_display_top, pt.menu_display_bottom, pt.display_on_mobile_custom_3, pt.display_on_mobile_custom_2, pt.display_on_mobile_custom_1, pt.display_on_desktop_custom_3, pt.display_on_desktop_custom_2, pt.display_on_desktop_custom_1, pt.active, pt.deleted, pt.display_bottom_slider, pt.display_on_hp,pt.sidebar_contact, pt.created, pt.updated, pt.short_desc, pt.primary_image, pt.primary_video, pt.video_gallery, pt.hp_banner_image, pt.ip_banner_image, pt.ip_banner_text, pt.ip_banner_image_mobile, pt.select_title, pt.select_text, pt.select_image, pt.select_video, pt.select_icon, pt.select_icon_mobile, pt.sidebar_icon, pt.sidebar_icon_hover, pt.tags, pt.auto_tags, pt.display_on_side, pt.use_title_as_ip_banner_text, pt.dominantBannerMobile, pt.canonical, pt.seo_canonical_id, pt.seo_canonical_custom, pt.rgb_liding_color, pt.a_must_for_enlistment,
pd.price, pd.wholesale, pd.pricecatalog, pd.pricesale, pd.quantity, pd.max_quantity, pd.min_quantity, pd.sku, pd.delivery_price, pd.zap,pd.type, pd.manufacturer_id, pd.model, pd.warranty, pd.payments, pd.related_products_cache_edited, pd.related_products_cache, pd.rivhit_id,
u.friandly_url,u.`type` AS url_type,u.real_url,t.group_id,t.type_id,t.filename,t.name as template_name,
(CASE WHEN pd.`quantity` IS NOT NULL AND pd.`quantity` <> '0' THEN 1 ELSE 0 END) AS inStock, canonical_pt.`title` as canonical_page_title,
canonical_pt.`template` as canonical_page_template,
(CASE WHEN p.`height`>0 THEN p.`height` ELSE (CASE WHEN canonical_p.`height` IS NOT NULL AND canonical_p.`height`>0 THEN canonical_p.`height` ELSE 0 END) END) AS height,
(CASE WHEN p.`width`>0 THEN p.`width` ELSE (CASE WHEN canonical_p.`width` IS NOT NULL AND canonical_p.`width`>0 THEN canonical_p.`width` ELSE 0 END) END) AS width,
(CASE WHEN p.`length`>0 THEN p.`length` ELSE (CASE WHEN canonical_p.`length` IS NOT NULL AND canonical_p.`length`>0 THEN canonical_p.`length` ELSE 0 END) END) AS length,
(CASE WHEN p.`weight`>0 THEN p.`weight` ELSE (CASE WHEN canonical_p.`weight` IS NOT NULL AND canonical_p.`weight`>0 THEN canonical_p.`weight` ELSE 0 END) END) AS weight,`mt`.`title` AS `manufacturer_title`,`mt`.`image` AS `manufacturer_image`,`mt_en`.`title` AS `manufacturer_en_title`,pc.`cat_id`,
(CASE WHEN pd.pricesale <> 0 THEN pd.pricesale ELSE pd.price END) AS finalprice
FROM `pages` as p
JOIN `pages_translations` as pt ON p.`id`=pt.`page_id`
JOIN `urls` as u ON u.`id`=pt.`url_id`
JOIN `templates` as t ON pt.`template`=t.`filename`
LEFT JOIN `products` as pd ON p.`id`=pd.`page_id`
LEFT JOIN `pages` as canonical_p ON canonical_p.`id`=pt.`canonical`
LEFT JOIN `pages_translations` as canonical_pt ON canonical_p.`id`=canonical_pt.`page_id` AND canonical_pt.`lang`=pt.`lang`
LEFT JOIN `manufacturers_translations` as mt ON pd.`manufacturer_id` = `mt`.`manufacturers_id` AND `mt`.`lang` = `pt`.`lang`
LEFT JOIN `manufacturers_translations` as mt_en ON `mt_en`.`manufacturers_id` = `pd`.`manufacturer_id` and `mt_en`.`lang` = 'en'
LEFT JOIN `product_cats` as pc ON pd.`page_id` = pc.`product_id`
ORDER BY pt.`deleted` ASC
) as res);
## products_prices_stock_view
CREATE VIEW products_prices_stock_view AS
(SELECT DISTINCT
res2.*,
(CASE WHEN (res2.pricesale <> 0 OR res2.sales_id IS NOT NULL) THEN 1 ELSE 0 END) AS is_on_sale,
(res2.`pricecatalog` - res2.`finalprice`) AS catelog_price_diff,
ROUND((100-((res2.`finalprice` / res2.`pricecatalog`)*100))) AS catelog_price_perc_diff
FROM (
SELECT DISTINCT
res.*,
(CASE
WHEN (res.`sales_discount_type`='per' AND res.`sales_apply_discount_on`='product_price' AND res.`sales_discount`>0) THEN ( (res.`normalprice` - ((res.`normalprice` * res.`sales_discount`) / 100)) )
WHEN (res.`sales_discount_type`='amt' AND res.`sales_apply_discount_on`='product_price' AND res.`sales_discount`>0) THEN ( (res.`normalprice` - res.`sales_discount`) )
WHEN (res.`sales_discount_type`='fix' AND res.`sales_apply_discount_on`='product_price' AND res.`sales_discount`<res.`normalprice`) THEN ( res.`sales_discount` )
ELSE (res.`normalprice`)
END) AS finalprice
FROM (
SELECT
pv2.id, pv2.price, pv2.wholesale, pv2.pricecatalog, pv2.pricesale, pv2.quantity, pv2.max_quantity, pv2.min_quantity, pv2.delivery_price, pv2.normalprice, st.`sales_id`,
(CASE WHEN (sap.`discount_type` IS NOT NULL AND sap.`discount_type`!='') THEN sap.`discount_type` ELSE sa.`discount_type` END) AS sales_discount_type,
(CASE WHEN (sap.`apply_discount_on` IS NOT NULL AND sap.`discount_type`!='') THEN sap.`apply_discount_on` ELSE sa.`apply_discount_on` END) AS sales_apply_discount_on,
(CASE WHEN (sap.`discount` IS NOT NULL AND sap.`discount_type`!='') THEN sap.`discount` ELSE sa.`discount` END) AS sales_discount
FROM (
SELECT DISTINCT
pv.id, pv.lang, pv.cat_id, pv.manufacturer_id, pv.price, pv.wholesale, pv.pricecatalog, pv.pricesale, pv.quantity, pv.max_quantity, pv.min_quantity, pv.delivery_price, pv.normalprice
FROM `page_view` as pv
WHERE pv.`group_id`='6' AND pv.`type_id`='3'
GROUP BY pv.`id`,pv.`lang`,pv.`cat_id` ORDER BY pv.`deleted` ASC
) as pv2
LEFT JOIN `sales_conditions` as sc ON ((`sc`.`start_date`<= CURRENT_DATE() AND `sc`.`end_date` >= CURRENT_DATE()) || `sc`.`ignor_end_start_date` = '1') AND `sc`.`is_coupon` = '0'
LEFT JOIN `sales` as s ON s.`id`=sc.`sales_id`
LEFT JOIN `sales_translations` as st ON st.`sales_id`=s.`id` AND st.`lang`=pv2.`lang` AND st.`active`='1' AND st.`deleted`='0'
LEFT JOIN `sales_actions` as sa ON sa.`sales_id`=st.`sales_id`
LEFT JOIN `sales_actions_cats` as sac ON sac.`cat_id` = pv2.`cat_id` AND sac.`sales_actions_id`=sa.`sales_id`
LEFT JOIN `sales_actions_manufacturers` as sam ON sam.`manufacturer_id` = pv2.`manufacturer_id` AND sam.`sales_actions_id`=sa.`sales_id`
LEFT JOIN `sales_actions_products` as sap ON sap.`product_id` = pv2.`id` AND sap.`sales_actions_id`=sa.`sales_id`
GROUP BY pv2.`id` ORDER BY st.`priority` DESC, s.`id` ASC, sap.`id` DESC
) as res
) as res2);
## products_sales_minimal_view
CREATE VIEW products_sales_minimal_view AS
(SELECT DISTINCT
res.`id`, res.`lang`, res.`sales_id`, res.`sales_discount_type`, res.`sales_apply_discount_on`, res.`sales_discount`,
(CASE
WHEN (res.`sales_discount_type`='per' AND res.`sales_apply_discount_on`='product_price' AND res.`sales_discount`>0) THEN ( (res.`normalprice` - ((res.`normalprice` * res.`sales_discount`) / 100)) )
WHEN (res.`sales_discount_type`='amt' AND res.`sales_apply_discount_on`='product_price' AND res.`sales_discount`>0) THEN ( (res.`normalprice` - res.`sales_discount`) )
WHEN (res.`sales_discount_type`='fix' AND res.`sales_apply_discount_on`='product_price' AND res.`sales_discount`<res.`normalprice`) THEN ( res.`sales_discount` )
ELSE (res.`normalprice`)
END) AS finalprice
FROM (
SELECT
pv2.`id`, pv2.`lang`, pv2.`normalprice`, st.`sales_id`,
(CASE WHEN (sap.`discount_type` IS NOT NULL AND sap.`discount_type`!='') THEN sap.`discount_type` ELSE sa.`discount_type` END) AS sales_discount_type,
(CASE WHEN (sap.`apply_discount_on` IS NOT NULL AND sap.`discount_type`!='') THEN sap.`apply_discount_on` ELSE sa.`apply_discount_on` END) AS sales_apply_discount_on,
(CASE WHEN (sap.`discount` IS NOT NULL AND sap.`discount_type`!='') THEN sap.`discount` ELSE sa.`discount` END) AS sales_discount
FROM (
SELECT DISTINCT
pv.`id`, pv.`lang`, pv.`cat_id`, pv.`manufacturer_id`, pv.`normalprice`
FROM `page_view` as pv
WHERE pv.`group_id`='6' AND pv.`type_id`='3'
GROUP BY pv.`id`,pv.`lang`,pv.`cat_id` ORDER BY pv.`deleted` ASC
) as pv2
LEFT JOIN `sales_conditions` as sc ON ((`sc`.`start_date`<= CURRENT_DATE() AND `sc`.`end_date` >= CURRENT_DATE()) || `sc`.`ignor_end_start_date` = '1') AND `sc`.`is_coupon` = '0'
LEFT JOIN `sales` as s ON s.`id`=sc.`sales_id`
LEFT JOIN `sales_translations` as st ON st.`sales_id`=s.`id` AND st.`lang`=pv2.`lang` AND st.`active`='1' AND st.`deleted`='0'
LEFT JOIN `sales_actions` as sa ON sa.`sales_id`=st.`sales_id`
LEFT JOIN `sales_actions_cats` as sac ON sac.`cat_id` = pv2.`cat_id` AND sac.`sales_actions_id`=sa.`sales_id`
LEFT JOIN `sales_actions_manufacturers` as sam ON sam.`manufacturer_id` = pv2.`manufacturer_id` AND sam.`sales_actions_id`=sa.`sales_id`
LEFT JOIN `sales_actions_products` as sap ON sap.`product_id` = pv2.`id` AND sap.`sales_actions_id`=sa.`sales_id`
WHERE
(
(sa.`apply_discount_on_all_product`='0' AND sa.`action_use_categories_list`='0' AND sa.`action_use_manufacturers_list`='0') OR
((sa.`apply_discount_on_all_product`='1' AND sa.`action_use_categories_list`='1' AND sa.`action_use_manufacturers_list`='1') AND (sap.`id` IS NOT NULL OR sac.`id` IS NOT NULL OR sam.`id` IS NOT NULL)) OR
((sa.`apply_discount_on_all_product`='0' AND sa.`action_use_categories_list`='1' AND sa.`action_use_manufacturers_list`='1') AND (sac.`id` IS NOT NULL OR sam.`id` IS NOT NULL)) OR
((sa.`apply_discount_on_all_product`='1' AND sa.`action_use_categories_list`='0' AND sa.`action_use_manufacturers_list`='1') AND (sap.`id` IS NOT NULL OR sam.`id` IS NOT NULL)) OR
((sa.`apply_discount_on_all_product`='1' AND sa.`action_use_categories_list`='1' AND sa.`action_use_manufacturers_list`='0') AND (sap.`id` IS NOT NULL OR sac.`id` IS NOT NULL)) OR
((sa.`apply_discount_on_all_product`='1' AND sa.`action_use_categories_list`='0' AND sa.`action_use_manufacturers_list`='0') AND (sap.`id` IS NOT NULL)) OR
((sa.`apply_discount_on_all_product`='0' AND sa.`action_use_categories_list`='1' AND sa.`action_use_manufacturers_list`='0') AND (sac.`id` IS NOT NULL)) OR
((sa.`apply_discount_on_all_product`='0' AND sa.`action_use_categories_list`='0' AND sa.`action_use_manufacturers_list`='1') AND (sam.`id` IS NOT NULL))
)
GROUP BY pv2.`id`, pv2.`lang` ORDER BY st.`priority` DESC, s.`id` ASC, sap.`id` DESC
) as res);
## page_view_with_sales
CREATE VIEW page_view_with_sales AS
(SELECT DISTINCT
res.*,
(CASE WHEN (res.pricesale <> 0 OR res.`sales_id` IS NOT NULL) THEN 1 ELSE 0 END) AS is_on_sale,
(res.`pricecatalog` - res.`finalprice`) AS catelog_price_diff,
ROUND((100-((res.`finalprice` / res.`pricecatalog`)*100))) AS catelog_price_perc_diff
FROM (
SELECT DISTINCT
p.id,p.name,p.inner_id,p.sort,p.assigned_cat_id,p.assigned_manufacturer_id,
pt.page_id, pt.lang, pt.title, pt.su_title, pt.zap_title, pt.text, pt.textmobile, pt.url_id, pt.template, pt.menu_name, pt.page_title, pt.meta_description, pt.default_child_description, pt.default_text_for_child_manufacturer_products_list, pt.meta_keywords, pt.heads_meta, pt.no_index_no_follow, pt.show_stock_progress_bar, pt.menu_display_primery, pt.menu_display_top, pt.menu_display_bottom, pt.display_on_mobile_custom_3, pt.display_on_mobile_custom_2, pt.display_on_mobile_custom_1, pt.display_on_desktop_custom_3, pt.display_on_desktop_custom_2, pt.display_on_desktop_custom_1, pt.active, pt.deleted, pt.display_bottom_slider, pt.display_on_hp,pt.sidebar_contact, pt.created, pt.updated, pt.short_desc, pt.primary_image, pt.primary_video, pt.video_gallery, pt.hp_banner_image, pt.ip_banner_image, pt.ip_banner_text, pt.ip_banner_image_mobile, pt.select_title, pt.select_text, pt.select_image, pt.select_video, pt.select_icon, pt.select_icon_mobile, pt.sidebar_icon, pt.sidebar_icon_hover, pt.tags, pt.auto_tags, pt.display_on_side, pt.use_title_as_ip_banner_text, pt.dominantBannerMobile, pt.canonical, pt.seo_canonical_id, pt.seo_canonical_custom, pt.rgb_liding_color, pt.a_must_for_enlistment,
pd.price, pd.wholesale, pd.pricecatalog, pd.pricesale, pd.quantity, pd.max_quantity, pd.min_quantity, pd.sku, pd.delivery_price, pd.zap,pd.type, pd.manufacturer_id, pd.model, pd.warranty, pd.payments, pd.related_products_cache_edited, pd.related_products_cache, pd.rivhit_id,
u.friandly_url,u.`type` AS url_type,u.real_url,t.group_id,t.type_id,t.filename,t.name as template_name,
(CASE WHEN pd.`quantity` IS NOT NULL AND pd.`quantity` <> '0' THEN 1 ELSE 0 END) AS inStock, canonical_pt.`title` as canonical_page_title,
canonical_pt.`template` as canonical_page_template,
(CASE WHEN p.`height`>0 THEN p.`height` ELSE (CASE WHEN canonical_p.`height` IS NOT NULL AND canonical_p.`height`>0 THEN canonical_p.`height` ELSE 0 END) END) AS height,
(CASE WHEN p.`width`>0 THEN p.`width` ELSE (CASE WHEN canonical_p.`width` IS NOT NULL AND canonical_p.`width`>0 THEN canonical_p.`width` ELSE 0 END) END) AS width,
(CASE WHEN p.`length`>0 THEN p.`length` ELSE (CASE WHEN canonical_p.`length` IS NOT NULL AND canonical_p.`length`>0 THEN canonical_p.`length` ELSE 0 END) END) AS length,
(CASE WHEN p.`weight`>0 THEN p.`weight` ELSE (CASE WHEN canonical_p.`weight` IS NOT NULL AND canonical_p.`weight`>0 THEN canonical_p.`weight` ELSE 0 END) END) AS weight,`mt`.`title` AS `manufacturer_title`,`mt`.`image` AS `manufacturer_image`,`mt_en`.`title` AS `manufacturer_en_title`,pc.`cat_id`,
(CASE WHEN pd.`pricesale` <> 0 THEN pd.`pricesale` ELSE pd.`price` END) AS normalprice,
(CASE
WHEN (psmv.`finalprice` IS NOT NULL) THEN (psmv.`finalprice`)
WHEN (pd.`pricesale` <> 0) THEN (pd.`pricesale`)
ELSE (pd.`price`)
END) AS finalprice,
psmv.`sales_id`, psmv.`sales_discount_type`, psmv.`sales_apply_discount_on`, psmv.`sales_discount`
FROM `pages` as p
JOIN `pages_translations` as pt ON p.`id`=pt.`page_id`
JOIN `urls` as u ON u.`id`=pt.`url_id`
JOIN `templates` as t ON pt.`template`=t.`filename`
LEFT JOIN `products` as pd ON p.`id`=pd.`page_id`
LEFT JOIN `pages` as canonical_p ON canonical_p.`id`=pt.`canonical`
LEFT JOIN `pages_translations` as canonical_pt ON canonical_p.`id`=canonical_pt.`page_id` AND canonical_pt.`lang`=pt.`lang`
LEFT JOIN `manufacturers_translations` as mt ON pd.`manufacturer_id` = `mt`.`manufacturers_id` AND `mt`.`lang` = `pt`.`lang`
LEFT JOIN `manufacturers_translations` as mt_en ON `mt_en`.`manufacturers_id` = `pd`.`manufacturer_id` and `mt_en`.`lang` = 'en'
LEFT JOIN `product_cats` as pc ON pd.`page_id` = pc.`product_id`
LEFT JOIN `products_sales_minimal_view` as psmv ON pd.`page_id` = psmv.`id`
ORDER BY pt.`deleted` ASC
) as res);
## add_get_grid
CREATE VIEW add_get_grid AS (
SELECT sq.*, (CASE WHEN (sq.`auto_created`='1' AND sq.`edited_by_admin`='0') THEN (1) ELSE (0) END) as auto_bundle,
(CASE
WHEN (sq.`discount_type`='per' AND sq.`discount_type_val`>0) THEN ( ROUND( (sq.`normal_price` - ((sq.`normal_price` * sq.`discount_type_val`) / 100)),2 ) )
WHEN (sq.`discount_type`='amt' AND sq.`discount_type_val`>0) THEN ( ROUND( (sq.`normal_price` - sq.`discount_type_val`),2 ) )
WHEN (sq.`discount_type`='fix' AND sq.`discount_type_val`<sq.`normal_price`) THEN ( ROUND( sq.`discount_type_val`,2 ) )
WHEN (sq.`discount_type`='add' AND sq.`discount_type_val`>0) THEN ( ROUND( (sq.`base_item_price` + sq.`discount_type_val`),2 ) )
ELSE ( ROUND( sq.`normal_price`,2 ) )
END) AS bundle_price
FROM (
SELECT sq2.*, ROUND(SUM(sq2.finalprice),2) as normal_price, ROUND(SUM(sq2.wholesale),2) as wholesale_price FROM (
SELECT DISTINCT ag.*, agt.`lang`, agt.`title`, agt.`active`, agt.`deleted`,
pv2.`finalprice` AS base_item_price,
pv2.`title` AS base_item_title,
(CASE WHEN (pv2.`active`='1' AND pv2.`inStock`='1') THEN 1 ELSE 0 END) AS base_item_available,
pv2.`primary_image` AS base_item_image,
IFNULL(pv.`finalprice`,0) AS finalprice,
IFNULL(pv.`wholesale`,0) AS wholesale
FROM
`add_get` as ag
JOIN `add_get_translations` as agt ON ag.`id`=agt.`add_get_id` AND agt.`deleted`='0'
LEFT JOIN `add_get_items` AS agi ON agi.`add_get_id`=ag.`id`
LEFT JOIN `page_view_with_sales_index` as pv ON (pv.`id`=agi.`item_id` || pv.`id`=ag.`base_item_id`) AND pv.`lang`=agt.`lang` AND pv.`deleted`='0'
LEFT JOIN `page_view_with_sales_index` as pv2 ON pv2.`id`=ag.`base_item_id` AND pv2.`lang`=agt.`lang` AND pv2.`deleted`='0'
GROUP BY ag.`id`, agt.`lang`, pv.`id`
) as sq2 GROUP BY sq2.id
) as sq
GROUP BY sq.`id`
ORDER BY sq.`id` DESC
);
这是错误:
ERROR 1349 (HY000) at line 1: View's SELECT contains a subquery in the FROM clause
我读到,这个错误可能会解决后升级到5.7 mysql。我尝试了一下,升级到mysql 5.7,成功导入了这个文件。
但是当尝试加载网站时,它会出错,说数据库中有错误(我使用的是virtualbox,所以我在升级前返回了快照,所以我记不清了,但我会尝试找到错误并进行编辑。
编辑:
我从mysql文档中了解到mysql不支持 SELECT
所以我在mysql文档的指导下升级了mysql,现在我可以成功地导入 .sql
但我得到这个错误:
SQL/DB Error -- [Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db_name.pv.name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by]
我现在也不能使用mysql工作台。当我被要求输入密码时,我会把它留空,因为我的电脑上没有密码 root
但是我得到了这个错误:
您尝试将用户“root”从主机连接到的服务器失败localhost:3306:拒绝用户“root”@“localhost”的访问(使用密码:否)
Cannot Connect to Database Server
Please:
1 Check that mysql is running on server localhost
2 Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the root has rights to connect to localhost from your address (mysql rights define what clients can connect to the server and from which machines)
4 Make sure you are both providing a password if needed and using the correct password for localhost connecting from the host address you're connecting from
我猜这是相关的,但我不知道如何解决它。
1条答案
按热度按时间eanckbw91#
这似乎是这个问题的重复:选择列表不在GROUPBY子句中,并且包含未聚合的列。。。。与sql不兼容\u mode=only \u full \u group by
这看起来像是一个严格的sql模式。
您可以通过如下方式编辑my.cnf文件来更改它