如何在where子句中使用json值显示多行?

时间:2018-08-09 06:32:03

标签: mysql

我的桌子看起来像这样。

****************************************************
CREATE TABLE `order` (
  `txn_id` VARCHAR(50) DEFAULT NULL,
  `payload` VARCHAR(4000) DEFAULT NULL ,
  `version` VARCHAR(10) DEFAULT NULL,
  PRIMARY KEY (`block_id`)
) ENGINE=INNODB AUTO_INCREMENT=86 DEFAULT CHARSET=latin1;



Insert into order  values
('145553',{"ordernumber":"PO_1323320","itemno":"44655644","description":"item001","quantity":"1"}', '1'),
('145554',{"ordernumber":"PO_1323321","itemno":"44655645","description":"item001","quantity":"1"}', '1'),
('145555',{"ordernumber":"PO_1323322","itemno":"44655646","description":"item001","quantity":"1"}', '1'),




SELECT JSON_EXTRACT(payload, '$.ordernumber') 
FROM order
Select * from order  where $.ordernumber(SELECT JSON_EXTRACT(payload, '$.ordernumber') 
FROM order)

我将在客户端选择订单号和商品编号。我正在使用节点js连接并从mySQL查询。通过传递这两个参数,我必须获取MySQL中的行。我该怎么办?

0 个答案:

没有答案