Jump to content

Problem using GROUP_CONCAT


Shadowing
Go to solution Solved by Shadowing,

Recommended Posts

Hey guys having issues trying to get group_concat to work. If its even what im looking for :P

 

All these columns are INT accept bombers which is a string

What I want to do is also add each bombers columns with a - seperator

 

 

"SELECT SUM(naqahdah) , COUNT(*) , SUM(slaves) , SUM(jaffa) , SUM(unas) ,  

  SUM(resources) , SUM(death_gliders), SUM(threaders) , GROUP_CONCAT(bombers separator '-') , 

  SUM(staff_cannons) , SUM(naqahdah_mines) FROM planets WHERE id= $user_id GROUP BY id";

 

 

 

If anyone could kindly help

Edited by Shadowing
Link to comment
Share on other sites

Thanks for teh reply Barand  :)

 

bombers look like 50000-5000-45600-54369

 

 

I need the return to end up in the same pattern when adding all the bombers columsn up where id equals user_id

Edited by Shadowing
Link to comment
Share on other sites

I'm unsure where your confusion lies Barand

 

 

I need mysql to return in the same pattern when all bombers rows are being added together

 

so

bombers row1 looks like  '50-6-7-8-3-4-5'

bombers row2 looks like '50-6-7-8-3-4-5'

bombers row3 looks like '50-6-7-8-3-4-5'

 

i need the return to be '50-6-7-8-3-4-5-50-6-7-8-3-4-5-50-6-7-8-3-4-5'

Edited by Shadowing
Link to comment
Share on other sites

  • Solution

Alright I solved my problem using IFNULL

 

 

GROUP_CONCAT(NULLIF(bombers,'') separator '-') AS bombers

 

 

Thanks for the amazing help you provided Barand you are a true saint to this forum of phpfreaks.com

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.