In mySQL I use GROUP_CONCAT
SELECT
visits,
GROUP_CONCAT(token) as token
FROM general
GROUP BY visits
but the problem is that I have a huge number of rows with same visits and using PHP it does not allow me to print everything.
Is there a workaround for this?
I ran into the same issue when I was trying to group_concat a string that was too big.. so what I did to solve it was this
SET SESSION group_concat_max_len = 10000000000000000;
this is a temporary function meaning that it wont actually change it forever but only in the scope of your query session.
I wouldn't recommend changing it forever but only for the scope of your query... that way you aren't using up a lot of memory space for that one function.. when you probably don't need to use it all the time
with that aside if you really want to just reset it to a larger length and not change it for your session then just remove session from the query to set it.
so your query should be like this
SET SESSION group_concat_max_len = 10000000000000000; -- # -- or whatever size you need to make it
SELECT
visits,
GROUP_CONCAT(token) as token
FROM general
GROUP BY visits;
if you are still getting an error as @spencer7593 correctly noted.. you may need to change your max_allowed_packet
... you can do that from this SO POST
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With