vladimirProp
vladimirProp

Reputation: 251

Use result of group concat in subquery Mysql

hello I would like to use result of rows in subquery

group_concat(TI2.entry_id)

result of this is for example two ids 102,414 and this is display in results.

But when i try to use this rows in another query

SELECT   (SELECT  sum(transaction_item.item_price) from transaction_item where transaction_item.entry_id IN (group_concat(TI2.entry_id))) AS new 

i got sum only for one id.

Any idea whats wrong here, using another query for this is not an option

Upvotes: 0

Views: 126

Answers (1)

Nishant Nair
Nishant Nair

Reputation: 2007

Try using nest query in where clause

  SELECT  (SELECT  sum(transaction_item.item_price) from 
  transaction_item where transaction_item.entry_id IN 
  (select group_concat(entry_id) from transaction_item group by entry_id))
  AS new 

Upvotes: 1

Related Questions