Mysql Group_concat where in again group concat how can i manage

Chirag Pipariya

when i run this query result is getting

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  

but i want above query "IN" value i getting from other table so i am creating new query but i am not getting result

see below new query here

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  
Abhi

Remove GROUP_CONCAT from the subquery:

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  

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MySQL group_concat with where clause

From Dev

mysql query, how can i get top 5 downloads with GROUP_CONCAT

From Dev

mysql query, how can i get top 5 downloads with GROUP_CONCAT

From Dev

How can I combine GROUP_CONCAT and LEFT JOIN?

From Dev

How can I use GROUP_CONCAT in Rails?

From Dev

How can I use group_concat on an entire subquery?

From Dev

MySQL Group_Concat Not In

From Dev

MySQL: How to sort when using concat in group_concat?

From Dev

How to get mysql Group_Concat to work with additional CONCAT information?

From Dev

MySQL: How to sort when using concat in group_concat?

From Dev

MySQL's Group_Concat function miss the nulls. How can group the rows including NULLs.

From Dev

If condition with group_concat in mysql

From Dev

Mysql with GROUP_CONCAT in subselect

From Dev

Mysql GROUP_CONCAT and IN query

From Dev

MySQL group_concat with join

From Dev

MySQL group_concat and count

From Dev

mySQL GROUP_CONCAT - Query

From Dev

MySQL: Nested GROUP_CONCAT

From Dev

Inversing group_concat in Mysql

From Dev

MySQL group_concat problems

From Dev

Mysql group_concat with distinct and where gives strange results

From Dev

MySQL group_concat and nest with another group_concat

From Dev

MySQL group_concat and nest with another group_concat

From Dev

Error when I used GROUP_CONCAT on mysql query

From Dev

How do I use JPA 2.1's CriteriaBuilder.function with MySQL's "GROUP_CONCAT"?

From Dev

How to COUNT MySQL results when I use “GROUP_CONCAT” and “HAVING” in the query?

From Dev

How do I approach queries like this in MySQL, Group_Concat maybe?

From Dev

MySQL GROUP_CONCAT excluding group value

From Dev

Mysql - Possible solutions for "group by group_concat()"?

Related Related

HotTag

Archive