Jump to content

Group Concat Fails


unemployment

Recommended Posts

My group concat does not work at all. It is not concatinating the action_id and action descriptions into a delimited list.

 

SELECT
                users.id,
                users.firstname,
                users.lastname,
                users.username,
                companies.industry AS industry,
                companies.stage AS stage,
                companies.companytag AS companytag,
                '' AS gender,
                '' AS accounttype,
                companies.country,
                companies.state,
                companies.city,
                UNIX_TIMESTAMP(`company_actions`.`time`) AS `approved_date`,
                '' AS FeedId,
                companies.companyname AS FeedFirstName,
                '' AS FeedLastName,
                '' AS FeedUserName,
                GROUP_CONCAT(actions.actionsdescription SEPARATOR '~#') AS `action_ids`,
                GROUP_CONCAT(company_actions.details SEPARATOR '~#') AS `action_details`
            FROM users
            INNER JOIN employees ON employees.userid = users.id
            INNER JOIN companies ON employees.companyid = companies.companyid
            INNER JOIN company_actions ON company_actions.company_id = companies.companyid
            INNER JOIN actions ON company_actions.action_id = actions.id
		WHERE users.id = ${uid}
            AND `company_actions`.`time` < ${time}
            GROUP BY 
                users.firstname,
                users.lastname,
                users.username,
                industry,
                stage,
                companytag,
                gender,
                accounttype,
                companies.country,
                companies.state,
                companies.city,
                `approved_date`,
                FeedId,
                FeedFirstName,
                FeedLastName

Link to comment
https://forums.phpfreaks.com/topic/235443-group-concat-fails/
Share on other sites

what errors do you receive when you use mysql_error().?

 

I don't receive any errors, but it still doesn't concatenate my rows.

 

I assume that it would do this for example

 

uid  aid

1      2

1      3

1      4

 

and turn it into something like...

 

uid    aid

1        2, 3, 4

 

Is that what is supposed to happen?

Link to comment
https://forums.phpfreaks.com/topic/235443-group-concat-fails/#findComment-1210133
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.