2015-10-20 158 views
0

我想在我SQL創建以下存儲過程:MySQL中創建新的存儲過程

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 
但是

,它拋出錯誤:

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 'from tip_entry_line_item LEFT JOIN select app_gl_bridge.gl_code,app_gl_bridge.' at line 4

回答

0

您的SQL語法看起來有點混亂給我。有沒有從UPDATE語法,以及表引用應設置部位之前。

UPDATE [LOW_PRIORITY] [IGNORE] table_reference 
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... 
[WHERE where_condition] 
[ORDER BY ...] 
[LIMIT row_count] 

MySQL doc

相同的SELECT子查詢(GROUP BY應該是在年底),還你必須把

我不知道您的查詢應該做的括號它,你可以把關於UPDATE和子查詢看看這個答案:MySQL - UPDATE query based on SELECT Query