[英]MYSQL Creating new Stored Procedure
我正在嘗試在MY SQL中創建以下存儲過程:
create procedure UpdateLineItemGAPSTATOTH(IN TIP_LI_ID INT)
BEGIN
Update tip_entry_line_item set tip_entry_line_item.ACCT_NAME = app_gl_bridge.gl_description
from tip_entry_line_item LEFT JOIN
select app_gl_bridge.gl_code,app_gl_bridge.gl_description
FROM app_gl_bridge GROUP BY gl_code,gl_description ON tip_entry_line_item.GL_ACCT_CODE = app_gl_bridge.gl_code
WHERE tip_entry_line_item.TIP_LI_ID = TIP_LI_ID;
END
但是,它拋出錯誤:
您的SQL語法有誤; 請檢查與您的MySQL服務器版本相對應的手冊,以獲取正確的語法,以在“從tip_entry_line_item左聯接選擇app_gl_bridge.gl_code,app_gl_bridge”附近使用。 在第4行
您的SQL語法對我來說有點混亂。 UPDATE語法中沒有FROM,並且表引用應該放在SET部分之前。
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
與SELECT子查詢相同(GROUP BY應該在末尾),並且還必須將其放在方括號之間
我不確定您的查詢應該做什么,您可以看一下有關UPDATE和子查詢的答案: MySQL-基於SELECT查詢的UPDATE查詢
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.