Forum Moderators: open

Message Too Old, No Replies

Form a query

         

orion_rus

10:53 am on Sep 5, 2006 (gmt 0)

10+ Year Member



I need some help in a query
i have database where i need to find all inclusive words from table such this:
ids = word
1 concrete
1 metal
1 beton
2 seem
2 make
3 find

i need following database output
1 concrete,metal,beton
2 seem,make
3 find

how i can make this?

Rebrandt

12:38 pm on Sep 5, 2006 (gmt 0)

10+ Year Member



Hi, if this is MySQL database then:

SELECT id, GROUP_CONCAT(word SEPARATOR ', ') AS words
FROM table
GROUP BY id

orion_rus

6:10 am on Sep 6, 2006 (gmt 0)

10+ Year Member



i have a mysql 4.0 and haven't group_concat, may be somebody have another way?

coopster

5:11 pm on Sep 6, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You won't be able to use subqueries either then. You'll have to loop and put them together yourself. Here is an example in PHP ...
[webmasterworld.com...]