Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 选择in子句中的值不返回实际值_Mysql - Fatal编程技术网

Mysql 选择in子句中的值不返回实际值

Mysql 选择in子句中的值不返回实际值,mysql,Mysql,在下面的查询中 mysql> select -> what_to_wear_under, -> (select group_concat(value) from eav_attribute_option_value where option_id in (what_to_wear_under) and store_id = 1 ) as what_to_wear_under -> from -> catalog_produc

在下面的查询中

mysql> select
    ->     what_to_wear_under,
    -> (select group_concat(value) from eav_attribute_option_value where option_id in (what_to_wear_under) and store_id = 1  ) as what_to_wear_under
    -> from
    -> catalog_product_flat_1 where brief_coverage is not null and brief_coverage > 0 limit 1\G
*************************** 1. row ***************************
what_to_wear_under: 2028,2031,2032
what_to_wear_under: Churidar Kurtas
1 row in set, 2 warnings (0.00 sec)
当我在(what-to-wear-under)中使用选项id时,what-to-wear-under有三个值

但如果我直接使用值,它会正确返回值

mysql> select     what_to_wear_under, (select group_concat(value) from eav_attribute_option_value where option_id in (2028,2031,2032) and store_id = 1  ) as what_to_wear_under from  catalog_product_flat_1 where brief_coverage is not null and brief_coverage > 0 limit 1\G
*************************** 1. row ***************************
what_to_wear_under: 2028,2031,2032
what_to_wear_under: Churidar Kurtas,Denims,Dresses
1 row in set (0.00 sec)

你能帮助我们如何修改查询一个值以获得三个值吗?

你不能在这样的列中进行比较,不管他包含逗号分隔的值,它都会把他看作是1个值。 您可以使用like来实现这一点(我不确定mysql的语法,所以您可能需要使用concat来调整它):


你不能在这样的专栏中进行比较,不管他包含逗号分隔的值,他都会把他看作1个值。 您可以使用like来实现这一点(我不确定mysql的语法,所以您可能需要使用concat来调整它):


你应该使用prepare QueryAnks你应该使用prepare QueryTanks,但现在它返回了5个值:Churidar Kurtas,牛仔,连衣裙,运动胸罩,T恤胸罩期望是什么:Churidar Kurtas,牛仔,连衣裙,运动胸罩,但现在它返回了5个值:Churidar Kurtas,牛仔,连衣裙,运动胸罩,T恤文胸是你应该穿的:Churidar Kurtas,牛仔裤,连衣裙
select
->     what_to_wear_under,
-> (select group_concat(value) from eav_attribute_option_value where  what_to_wear_under like concat('%',option_id,'%') and store_id = 1  ) as what_to_wear_under
-> from
-> catalog_product_flat_1 where brief_coverage is not null and brief_coverage > 0 limit 1\G