mysql - How to group_concat() and group by with null values? -


i have 2 tables this:

publications

publications id        |  publications field id | publications description 1000                   |  1                     | john  1000                   |  2                     | 2014 1000                   |  4                     | aa@... 1000                   |  6                     | 123-456-789 

id = 1000 means 1 book , detail description (author name, year, e-mail,tel)

registry

   publications field id  | component     1                      | author name     2                      | year     3                      | date     4                      | e-mail     5                      | price     6                      | tel 

registry means book's format table

i want merge 2 tables this:

publications id | publications description 1000            | john,2014,null,aa@..,null,123-456-789 

null means book(id=1000)'s field id 3 , 5 null

so, use left join:

select registry.publications field id,component,publications id, publications description registry  left join  publications on publications.publications field id = registry.publications field id  

but result is:

publications field id  | component   | publications id   | publications description 1                      | author name | 1000              | john 2                      | year        | 1000              | 2014 3                      | date        | null              | null 4                      | e-mail      | 1000              | aa@.. 5                      | price       | null              | null 6                      | tel         | 1000              | 123-456-789 

i know next step use group_concat(ifnull(publications description,'null')) how group publications id? when publications id null?


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -