2015-10-20 152 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