小编cot*_*ros的帖子

如何控制 JSON_ARRAYAGG 如何对结果进行排序

我正在测试 MySQLJSON_ARRAYJSON_ARRAYAGG函数,以便将一些应用程序昂贵的进程移动到 SQL 存储函数。

在下面的电子商务应用程序示例中,我尝试检索用户的购物车,而不是作为来自 cart_items 表的行结果集,而是作为包含 Javascript 回调函数呈现购物车所需的所有信息的 JSON 字符串。

我有一张cart包含一般购物车信息的表格

create table user_cart (
  cart_id  integer unsigned primary key,
  user_id  integer unsigned not null,
);
Run Code Online (Sandbox Code Playgroud)

cart_item明细表,

create table cart_item (
  cart_item_id  integer unsigned primary key auto_increment,
  cart_id       integer unsigned not null,
  product_id    integer unsigned not null,

  qty           integer unsigned not null,
  ref           varchar(15) not null,

  -- total
  base          double default 0.0,
  tax           double default 0.0,
  tax_pct       double default 0.0,
  total …
Run Code Online (Sandbox Code Playgroud)

mysql json

6
推荐指数
1
解决办法
2104
查看次数

标签 统计

json ×1

mysql ×1