Jump to content

Concat results?


Azu

Recommended Posts

Gives me an error about there being more then 1 result from the query or something.

 

I just want to take all of the rows in all of the columns in the table and concat them into a single result, separated by commas. (well not ALL the columns, but a lot of them)

Link to comment
https://forums.phpfreaks.com/topic/69520-concat-results/#findComment-349443
Share on other sites

I have like 5 rows.. let's call them row1 row2 row3 row4 row5

 

They are all pretty much the same but have different numbers in them

 

I want to take all of them from this table and put them into 1 result, so that I can use them as a subquery, and see if a certain number is in them.

Link to comment
https://forums.phpfreaks.com/topic/69520-concat-results/#findComment-349844
Share on other sites

I'm not sure how to approach this, at least not in a proper and efficient sense. How about something like this?

 

SELECT field FROM table WHERE field IN (

  SELECT DISTINCT foo1 AS pool FROM bar

  UNION

  SELECT DISTINCT foo2 AS pool FROM bar

  UNION

  SELECT DISTINCT foo3 AS pool FROM bar

)

Link to comment
https://forums.phpfreaks.com/topic/69520-concat-results/#findComment-349910
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.