这是我的MySQL程序。执行此操作时出错。
DELIMITER //
CREATE PROCEDURE GET_ORDER_HISTORY_LIST(IN distid int)
BEGIN
SELECT
ort.order_id,
ort.transaction_id,
ort.user_id,
ort.transaction_date,
ort.insert_by,
ort.organization_id,
odt.course_id,
count(odt.quantity),
ct.course_name,
ct.course_code
FROM cdp_order_master as ort
JOIN cdp_order_detail as odt ON odt.order_id = ort.order_id
JOIN cdp_course as ct ON ct.course_id = odt.course_id
WHERE ort.user_id = distid
GROUP BY ort.order_id
END //
DELIMITER ;
错误是
#1064 - 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 'END' at line 19
答案 0 :(得分:0)
DELIMITER //
CREATE PROCEDURE GET_ORDER_HISTORY_LIST(IN distid int)
BEGIN
SELECT
ort.order_id,
ort.transaction_id,
ort.user_id,
ort.transaction_date,
ort.insert_by,
ort.organization_id,
odt.course_id,
count(odt.quantity),
ct.course_name,
ct.course_code
FROM cdp_order_master as ort
JOIN cdp_order_detail as odt ON odt.order_id = ort.order_id
JOIN cdp_course as ct ON ct.course_id = odt.course_id
WHERE ort.user_id = distid
GROUP BY ort.order_id; //I had made change at this line.
END //
DELIMITER ;
您可以尝试以上查询。
这是SQL Fiddle。