Azu Posted September 16, 2007 Share Posted September 16, 2007 Can somebody PLEASE tell me what's why this isn't working? (example) select CONCAT_WS(',',(select foo1 from bar),(select foo2 from bar),(select foo3 from bar)); Quote Link to comment Share on other sites More sharing options...
effigy Posted September 16, 2007 Share Posted September 16, 2007 What does the error message say? Why are you using 3 separate selects if they're all pulling from the same table? Quote Link to comment Share on other sites More sharing options...
Azu Posted September 16, 2007 Author Share Posted September 16, 2007 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) Quote Link to comment Share on other sites More sharing options...
effigy Posted September 16, 2007 Share Posted September 16, 2007 SELECT CONCAT_WS(',', foo1, foo2, foo3) AS result FROM bar Quote Link to comment Share on other sites More sharing options...
Azu Posted September 16, 2007 Author Share Posted September 16, 2007 Thanks, it puts them into tens of thousands of different rows though.. o_o I'm trying to get it to return them in 1 row, separated by commas.. Quote Link to comment Share on other sites More sharing options...
effigy Posted September 17, 2007 Share Posted September 17, 2007 The commas separate the fields, but you're trying to condense this further into rows? What will separate the rows? Quote Link to comment Share on other sites More sharing options...
Azu Posted September 17, 2007 Author Share Posted September 17, 2007 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. Quote Link to comment Share on other sites More sharing options...
effigy Posted September 17, 2007 Share Posted September 17, 2007 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 ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.