0
JSON/MEMSQL存在問題。這裏是我的表:從MEMSQL讀取JSON
CREATE TABLE `MEMSQLPOLYGLOT` (
ID BIGINT AUTO_INCREMENT,
`DATA` JSON NULL,
PRIMARY KEY (ID)
);
這裏是我試圖讀取記錄:
insert into MEMTEST (DATA) values
('
{
"EnterpriseMessage" :
{
"Body" :
[
{
"AccountNumber":"ABCD",
"AdminCompany":null,
"BrokerNumber":"WWonka"
},
{
"AccountNumber":"CSNE",
"AdminCompany":null,
"BrokerNumber":"ZWiza"
}
],
"Header" :
{
"mimetye":"application/vnd.ms-powerpoint",
"destinationsystem":"ETL",
"requiresack":"FALSE",
"SimpArr":
[
"BYTS6181",
"EVU98124",
"Genesys"
],
"EmptyFile":1
}
}
}
');
我可以讀取頭中的SimpArr陣列。
SELECT DATA::EnterpriseMessage::Header::SimpArr from MEMTEST;
返回:
["BYTS6181","EVU98124","Genesys"]
我也可以通過在關鍵指標得到一個特定的值,如:
select JSON_EXTRACT_JSON(DATA::EnterpriseMessage::Body, 1) from MEMTEST;
這將返回SimpArr的第二個價值,因爲它是一個基於零的索引。
我還可以閱讀對象的身體數組:
select JSON_EXTRACT_JSON(DATA::EnterpriseMessage::Body, 0) from MEMTEST;
返回的第一個對象數組中:
{
"AccountNumber":"ABCD",
"AdminCompany":null,
"BrokerNumber":"WWonka"
}
但是,我無法找到一個方法來讀此對象的個別屬性。
任何人有任何想法?
感謝您的回覆!這工作。 – BamBam