homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

Query Question to return array

10+ Year Member

Msg#: 4340738 posted 10:44 am on Jul 18, 2011 (gmt 0)

Hi there,

I can't seem to figure this out. It's using MySQL.

I would like all cn.notes to be returned in an array if there are multiple notes.

I have this query:

SELECT *, GROUP_CONCAT(cn.notes) as all_notes FROM CUSTOMERS as c JOIN customer_notes as cn on cn.customers_id_fk = c.customer_id LEFT JOIN customer_url as cu on cu.customers_id_fk = c.customer_id LEFT JOIN sales as s on s.url_id_fk = cu.url_id WHERE c.customer_id = 6 GROUP BY cn.notes_id

This only returns the last note in the DB.

Any help would be great!



WebmasterWorld Administrator coopster us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4340738 posted 1:07 pm on Aug 18, 2011 (gmt 0)

Is cn.notes_id a PRIMARY KEY? If so, you are grouping on it and will only get 1 row returned.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved