用MySQL拼出JSON串
假如有一个表users中有二个字段username和email,可以用以下语句获取一个json字符串。
SELECT
CONCAT("[",
GROUP_CONCAT(
CONCAT("{username:'",username,"'"),
CONCAT(",email:'",email),"'}")
)
,"]")
AS json FROM users;
Reference: http://www.thomasfrank.se/mysql_to_json.html
No comments :
Post a Comment