mysql 查询的正则表达式
Regular expression for mysql query
我在mysql中有3条记录:
1. a:7:{s:10:"state_name";s:11:"West Bengal";s:7:"city_id";a:40:{i:0;s:4:"1166";i:1;s:4:"1454";i:2;s:4:"1455";i:3;s:4:"1456";i:4;s:4:"1458";i:5;s:4:"1459";i:6;s:4:"1460";i:7;s:4:"1461";i:8;s:4:"1463";i:9;s:4:"1464";i:10;s:4:"1465";i:11;s:4:"1466";i:12;s:4:"1468";i:13;s:4:"1469";i:14;s:4:"1470";i:15;s:4:"1471";i:16;s:4:"1473";i:17;s:4:"1474";i:18;s:4:"1475";i:19;s:4:"1476";i:20;s:4:"1478";i:21;s:4:"1479";i:22;s:4:"1480";i:23;s:4:"1481";i:24;s:4:"1483";i:25;s:4:"1484";i:26;s:4:"1485";i:27;s:4:"1486";i:28;s:4:"1488";i:29;s:4:"1489";i:30;s:4:"1490";i:31;s:4:"1491";i:32;s:4:"1493";i:33;s:4:"1494";i:34;s:4:"1495";i:35;s:4:"1496";i:36;s:4:"1498";i:37;s:4:"1499";i:38;s:4:"1500";i:39;s:4:"1501";}s:6:"gender";s:4:"male";s:3:"age";s:0:"";s:12:"category_ids";s:2:"68";s:16:"product_type_ids";s:2:"30";s:18:"min_purchase_price";s:1:"0";}
2. a:7:{s:10:"state_name";s:11:"West Bengal";s:7:"city_id";a:8:{i:0;s:4:"1465";i:1;s:4:"1466";i:2;s:4:"1467";i:3;s:4:"1471";i:4;s:4:"1475";i:5;s:4:"1476";i:6;s:4:"1478";i:7;s:4:"1479";}s:6:"gender";s:0:"";s:3:"age";s:4:"0-30";s:12:"category_ids";s:2:"58";s:16:"product_type_ids";s:0:"";s:18:"min_purchase_price";s:2:"50";}
3. a:7:{s:10:"state_name";s:11:"West Bengal";s:7:"city_id";a:1:{i:0;s:4:"1475";}s:6:"gender";s:6:"female";s:3:"age";s:4:"0-30";s:12:"category_ids";s:2:"58";s:16:"product_type_ids";s:0:"";s:18:"min_purchase_price";s:3:"100";}
列名 conditions_serialized
.
现在我正在尝试编写一个 sql 查询来获取具有 city_id
1475 的所有记录。
我的代码是这样的:
SELECT `main_table`.*, `rule_coupons`.`code` FROM `salesrule` AS `main_table` LEFT JOIN `salesrule_coupon` AS `rule_coupons` ON main_table.rule_id = rule_coupons.rule_id AND rule_coupons.is_primary = 1 WHERE (conditions_serialized regexp 'city_id";a:[0-9]*:{.*(i:[0-9]*;s:[0-9]*:"1475";)}')
但是这样只有2条记录显示第2条和第3条,而不是第1条。
你能检查我的查询并纠正为什么它没有显示全部吗?
提前致谢。
您正在明确寻找 1475
city_id";a:[0-9]*:{.*(i:[0-9]*;s:[0-9]*:"**1475**";)}
将其更改为此以从 3 条记录中获取记录。注:从3到5位数字
city_id";a:[0-9]*:{.*(i:[0-9]*;s:[0-9]*:"\d{3,5}";)}
我在mysql中有3条记录:
1. a:7:{s:10:"state_name";s:11:"West Bengal";s:7:"city_id";a:40:{i:0;s:4:"1166";i:1;s:4:"1454";i:2;s:4:"1455";i:3;s:4:"1456";i:4;s:4:"1458";i:5;s:4:"1459";i:6;s:4:"1460";i:7;s:4:"1461";i:8;s:4:"1463";i:9;s:4:"1464";i:10;s:4:"1465";i:11;s:4:"1466";i:12;s:4:"1468";i:13;s:4:"1469";i:14;s:4:"1470";i:15;s:4:"1471";i:16;s:4:"1473";i:17;s:4:"1474";i:18;s:4:"1475";i:19;s:4:"1476";i:20;s:4:"1478";i:21;s:4:"1479";i:22;s:4:"1480";i:23;s:4:"1481";i:24;s:4:"1483";i:25;s:4:"1484";i:26;s:4:"1485";i:27;s:4:"1486";i:28;s:4:"1488";i:29;s:4:"1489";i:30;s:4:"1490";i:31;s:4:"1491";i:32;s:4:"1493";i:33;s:4:"1494";i:34;s:4:"1495";i:35;s:4:"1496";i:36;s:4:"1498";i:37;s:4:"1499";i:38;s:4:"1500";i:39;s:4:"1501";}s:6:"gender";s:4:"male";s:3:"age";s:0:"";s:12:"category_ids";s:2:"68";s:16:"product_type_ids";s:2:"30";s:18:"min_purchase_price";s:1:"0";}
2. a:7:{s:10:"state_name";s:11:"West Bengal";s:7:"city_id";a:8:{i:0;s:4:"1465";i:1;s:4:"1466";i:2;s:4:"1467";i:3;s:4:"1471";i:4;s:4:"1475";i:5;s:4:"1476";i:6;s:4:"1478";i:7;s:4:"1479";}s:6:"gender";s:0:"";s:3:"age";s:4:"0-30";s:12:"category_ids";s:2:"58";s:16:"product_type_ids";s:0:"";s:18:"min_purchase_price";s:2:"50";}
3. a:7:{s:10:"state_name";s:11:"West Bengal";s:7:"city_id";a:1:{i:0;s:4:"1475";}s:6:"gender";s:6:"female";s:3:"age";s:4:"0-30";s:12:"category_ids";s:2:"58";s:16:"product_type_ids";s:0:"";s:18:"min_purchase_price";s:3:"100";}
列名 conditions_serialized
.
现在我正在尝试编写一个 sql 查询来获取具有 city_id
1475 的所有记录。
我的代码是这样的:
SELECT `main_table`.*, `rule_coupons`.`code` FROM `salesrule` AS `main_table` LEFT JOIN `salesrule_coupon` AS `rule_coupons` ON main_table.rule_id = rule_coupons.rule_id AND rule_coupons.is_primary = 1 WHERE (conditions_serialized regexp 'city_id";a:[0-9]*:{.*(i:[0-9]*;s:[0-9]*:"1475";)}')
但是这样只有2条记录显示第2条和第3条,而不是第1条。 你能检查我的查询并纠正为什么它没有显示全部吗?
提前致谢。
您正在明确寻找 1475
city_id";a:[0-9]*:{.*(i:[0-9]*;s:[0-9]*:"**1475**";)}
将其更改为此以从 3 条记录中获取记录。注:从3到5位数字
city_id";a:[0-9]*:{.*(i:[0-9]*;s:[0-9]*:"\d{3,5}";)}