sql获取错误' - >>'操作者

时间:2018-05-10 11:12:25

标签: mysql sql phpmyadmin

    CREATE PROCEDURE `getAssetDetailsforPDF`(
) BEGIN
Select
    class.Name as AssetName,
    getOperatingZoneName(
        ifnull(getoperatingzone(class.ID), 0)
    ) as OperatingZone,
    getTimetoFailure(
        class.ID
    ) as TagValue,
    class1.Name as LineName,
    details.Defintion - > > '$."Asset ID"' as definition
from
    asset_classification class
    left join
        asset_classification class1
    on  class1.ParentId = 2
    left join
        asset_details details
    on  details.Id in(
            select
                class.ID
        )
Where
    class.MCT_typeId = 5
and class.ParentId in(
        Select
            class1.ID
    )
group by
    class.Id
;
END
;
;

我有这个sql查询,我在将sql文件导入phpmyadmin数据库时遇到错误。

您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在“>”$附近使用正确的语法。“资产ID”'

修改 这是MySql的版本:

enter image description here

1 个答案:

答案 0 :(得分:4)

可能是您的MySQL不支持“->>'$ ...”之类的运算符。取而代之的是,您可以使用MySQL的json_extract()函数,如下所示:

    CREATE PROCEDURE `getAssetDetailsforPDF`(
) BEGIN
Select
    class.Name as AssetName,
    getOperatingZoneName(
        ifnull(getoperatingzone(class.ID), 0)
    ) as OperatingZone,
    getTimetoFailure(
        class.ID
    ) as TagValue,
    class1.Name as LineName,
json_extract(details.Defintion,'$."Asset ID"') as definition

from
    asset_classification class
    left join
        asset_classification class1
    on  class1.ParentId = 2
    left join
        asset_details details
    on  details.Id in(
            select
                class.ID
        )
Where
    class.MCT_typeId = 5
and class.ParentId in(
        Select
            class1.ID
    )
group by
    class.Id
;
END
;
;