gpt4 book ai didi

php - Mysql Group_concat 又在哪里 group concat 我该如何管理

转载 作者:行者123 更新时间:2023-11-29 12:27:25 28 4
gpt4 key购买 nike

当我运行此查询结果时

SELECT 
GROUP_CONCAT(`recipe_ingredient`.`recipeId`)
FROM `recipe_ingredient`
WHERE `recipe_ingredient`.`ingredientId`
IN(4,11,33,36,54,117,135,136,178,185,218,312,348,378)
ORDER BY `recipeId` ASC
<小时/>

但我想要从其他表获取上述查询“IN”值,因此我正在创建新查询,但我没有得到结果

在此处查看下面的新查询

SELECT 
GROUP_CONCAT(`recipe_ingredient`.`recipeId`)
FROM `recipe_ingredient`
WHERE `recipe_ingredient`.`ingredientId`
IN(
SELECT
GROUP_CONCAT(`ingredient`.`ingredientId`
ORDER BY `ingredient`.`ingredientId` ASC ) AS unlinkIng
FROM `ingredient`
WHERE `ingredient`.`ingredientId` IN(4,178) or `ingredient`.`linkIngredientPerent` IN(4,178)
)
ORDER BY `recipeId` ASC

最佳答案

从子查询中删除GROUP_CONCAT:

SELECT 
GROUP_CONCAT(`recipe_ingredient`.`recipeId`)
FROM
`recipe_ingredient`
WHERE
`recipe_ingredient`.`ingredientId` IN (SELECT `ingredient`.`ingredientId` AS unlinkIng
FROM `ingredient`
WHERE `ingredient`.`ingredientId` IN (4, 178)
OR `ingredient`.`linkIngredientPerent` IN (4, 178))
ORDER BY
`recipeId` ASC
<小时/>

关于php - Mysql Group_concat 又在哪里 group concat 我该如何管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28104506/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com