Jump to content
Joe Lusk

Building a list from a single row in multiple columns of a SQL table

Recommended Posts

So I am pulling a single row of data, but from multiple columns in a database table and making that into one string.  I have done this by using the SQL Get DataSet command like this

select MSPType, group_concat(email SEPARATOR ',') from useraccounts WHERE ClientID = '1204037' AND MSPType = 'XXX-MSP-Users' GROUP BY MSPTYpe

Then I Fetch row 1 from the dataset

This works and gives me the data that I want.  The problem is that it returns it under a variable name of @sqlgroup_concat(emailseparator',')@ (which shows properly in the debug window)

This variable name is unusable.  If I set a new variable name equal to it it just makes the new variable equal to that long variable name, not the contents of it. 

Any thoughts on this, or a better way to do it?

Share this post


Link to post
Share on other sites

Never mind. I just did this a different way and pulled each row one at a time and added to a running variable

Share this post


Link to post
Share on other sites

Just give the column a name. So do select MSPType, group_concat(email SEPARATOR ',') AS THISBIT from ...

Then you just wanna fetch @sqlTHISBIT@ from each row after that

  • Like 1

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

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