mysql - Can't figure out what's wrong with my GROUP_CONCAT -


i have following 2 tables:

 table `products`  productid   (int) primarykey  name        (varchar(25))  description (varchar(255))   table `images`  imageid            (int) primarykey  imagepath          (varchar(255))  imagedescription   (varchar(255))  products_productid (int) 

the images table contains images associated specific products. in one-to-many relation products table, product can have multiple images. column can null, (and in of cases of moment), images.imagedescription. select list of products, , in same query, images well. wrote following query:

select p.*,         group_concat(distinct concat(i.imagepath, '@', i.imagedescription) separator ',') _productimages  (select * products productid in (1,2,3,4,5,6,7)) p  left join images on i.products_productid = p.productid group p.productid 

all of selected products has @ least 1 associated row in images table, , first 3 has 3 associated rows in images table, yet, when query runs, , returns, _productimages null in every row. can point out doing wrong?

when concatenate string null result null. hence:

concat(i.imagepath, '@', coalesce(i.imagedescription, '')) 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -