以下是我的选择查询
select row_to_json(row(productid, product)) from tbl_pdts;
这将返回结果
{"f1":3988,"f2":"MYCET TAB"}
{"f1":3989,"f2":"MYCET COLD TAB"}
{"f1":3990,"f2":"TANDAM TAB"}"
{"f1":3991,"f2":"ACLOPEN 100 DT TAB"}
{"f1":3992,"f2":"COBEND TAB"}
但我需要将其作为
{"productid":3988,"product":"MYCET TAB"}
{"productid":3989,"product":"MYCET COLD TAB"}
{"productid":3990,"product":"TANDAM TAB"}
{"productid":3991,"product":"ACLOPEN 100 DT TAB"}
{"productid":3992,"product":"COBEND TAB"}
答案 0 :(得分:5)
select row_to_json(t)
from (
select productid, product from tbl_pdts
) t