gpt4 book ai didi

mysql - 导出的 Excel 文件显示错误

转载 作者:行者123 更新时间:2023-11-29 19:09:17 26 4
gpt4 key购买 nike

在 phpmyadmin 中执行以下查询,显示输出,但导出的 csv 文件中显示 SQL 错误。这是查询:

SELECT engageboost_customers.`id`             AS User_ID, 
Concat(`first_name`, ' ', `last_name`) AS Name,
`email`,
`phone`,
`created` AS Registration_date,
`lastlogin`,
Count(engageboost_ordermaster.id) AS Total_Orders,
Max(created_date) AS Last_Order_Date,
Min(created_date) AS First_order_date,
Sum(paid_amount) AS Total_Amount_Paid,
CASE
WHEN `device_token_ios` IS NULL THEN 'NO'
WHEN `device_token_android` IS NULL THEN 'NO'
ELSE 'YES'
end AS Active_App,
(SELECT CASE
WHEN applied_coupon IS NULL THEN 'No'
WHEN applied_coupon = '' THEN 'No'
ELSE 'Yes'
end AS 'secound_order_copon'
FROM engageboost_ordermaster
WHERE engageboost_customers.id = engageboost_ordermaster.customer_id
LIMIT 1, 1) AS Secound_order_coupon_utilized,
(SELECT CASE
WHEN applied_coupon IS NULL THEN 'No'
WHEN applied_coupon = '' THEN 'No'
ELSE 'Yes'
end AS 'secound_order_copon'
FROM engageboost_ordermaster
WHERE engageboost_customers.id = engageboost_ordermaster.customer_id
LIMIT 2, 1) AS Third_order_coupon_utilized,
(SELECT CASE
WHEN engageboost_ordermaster.refferal_code = '' THEN 'No'
WHEN engageboost_ordermaster.refferal_code IS NULL THEN 'No'
ELSE engageboost_ordermaster.refferal_code
end AS refcode
FROM engageboost_ordermaster
WHERE engageboost_customers.id = engageboost_ordermaster.customer_id
LIMIT 0, 1) AS 'firstordersecode'
FROM `engageboost_customers`
LEFT OUTER JOIN engageboost_ordermaster
ON engageboost_customers.id =
engageboost_ordermaster.customer_id
GROUP BY engageboost_customers.id

下面是我在 csv 文件中遇到的错误,但输出显示了。

#1064 - 您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,了解在第 1 行“FROM”附近使用的正确语法

最佳答案

你可以试试这个,伙计:

SELECT 
eo_1.`id` AS 'User_ID',
CONCAT(ec.`first_name`, ' ', ec.`last_name`) AS 'Name',
ec.`email`,
ec.`phone`,
ec.`created` AS 'Registration_date',
ec.`lastlogin`,
COUNT(eo_1.id) AS 'Total_Orders',
MAX(ec.created_date) AS 'Last_Order_Date',
MIN(ec.created_date) AS 'First_order_date',
SUM(ec.paid_amount) AS 'Total_Amount_Paid',
CASE
WHEN ec.`device_token_ios` IS NULL THEN 'NO'
WHEN ec.`device_token_android` IS NULL THEN 'NO'
ELSE 'YES'
END AS 'Active_App',
eo_2.secound_order_copon AS 'Secound_order_coupon_utilized',
eo_3.secound_order_copon AS 'Third_order_coupon_utilized',
eo_4.refcode AS 'firstordersecode'
FROM
engageboost_customers ec
LEFT JOIN engageboost_ordermaster eo_1 ON eo_1.customer_id = ec.id
LEFT JOIN (
SELECT
customer_id,
CASE
WHEN applied_coupon IS NULL THEN 'No'
WHEN applied_coupon = '' THEN 'No'
ELSE 'Yes'
END AS 'secound_order_copon'
FROM engageboost_ordermaster
LIMIT 1 , 1
) eo_2 ON eo_2.customer_id = ec.id
LEFT JOIN (
SELECT
customer_id,
CASE
WHEN applied_coupon IS NULL THEN 'No'
WHEN applied_coupon = '' THEN 'No'
ELSE 'Yes'
END AS 'secound_order_copon'
FROM engageboost_ordermaster
LIMIT 2 , 1
) eo_3 ON eo_3.customer_id = ec.id
LEFT JOIN (
SELECT
customer_id,
CASE
WHEN engageboost_ordermaster.refferal_code = '' THEN 'No'
WHEN engageboost_ordermaster.refferal_code IS NULL THEN 'No'
ELSE engageboost_ordermaster.refferal_code
END AS 'refcode'
FROM engageboost_ordermaster
LIMIT 0 , 1
) eo_4 ON eo_4.customer_id = ec.id
GROUP BY engageboost_customers.id;

关于mysql - 导出的 Excel 文件显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43223079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com