【发布时间】:2014-01-05 05:02:50
【问题描述】:
我已经努力但没有得到下面的解决方案..请帮助!!
CREATE PROCEDURE AccountLedgerViewUnderBank()
begin
WITH GroupInMainGroup (accountGroupId,HierarchyLevel) AS
(
select accountGroupId,
1 as HierarchyLevel
from tbl_AccountGroup where accountGroupId='9'
UNION ALL
select e.accountGroupId,
G.HierarchyLevel + 1 AS HierarchyLevel
from tbl_AccountGroup as e,GroupInMainGroup G
where e.groupUnder=G.accountGroupId
)
SELECT
ledgerId AS 'Account Ledger Id',
acccountLedgerName AS 'Account Ledger Name'
FROM tbl_AccountLedger
where accountGroupId IN (select accountGroupId from GroupInMainGroup
)
end ; //
错误显示
ERROR 1064 (42000):您的 SQL 语法有错误;检查手册 对应于您的 MySQL 服务器版本,以便在 'Group 附近使用正确的语法 InMainGroup (accountGroupId,HierarchyLevel) AS ( 选择 accountGroupId, 1 a' 在第 6 行
【问题讨论】:
-
MySQL 不支持公用表表达式。您需要升级到允许它们的 DBMS。
标签: mysql sql stored-procedures common-table-expression