I have two table, product and productimages
product table;
|----------------Table:product-|
|ID | tr_productname |
|---|--------------------------|
| 1 | Computer |
| 2 | Telephone |
| 3 | Television |
| 4 | Mouse |
|------------------------------|
productimages table;
|-----------Table:productimages-|
|ID | productid | imageurl |
|---|------------|--------------|
| 1 | 1 | computer.jpg |
| 2 | 1 | computer2.jpg|
| 3 | 2 | telephone.jpg|
| 4 | 2 | x.jpg |
| 5 | 2 | abc.jpg |
| 6 | 3 | tv.jpg |
|-------------------------------|
I want list products with image but if image does'nt seem to record. I want list all product.
MyQuery;
SELECT product.id, productcode, tr_productname, brand, imageurl
FROM product
LEFT JOIN productimages
ON product.id = productimages.productid
GROUP BY productimages.productid
ORDER BY product.id DESC
Result;
|-----------------------------------RESULT----|
|ID | tr_productname | imageurl |
|---|--------------------------|--------------|
| 1 | Computer | computer.jpg |
| 2 | Telephone | telephone.jpg|
| 3 | Television | tv.jpg |
|------------------------------|--------------|
But no product with "4" ID
group_concat(imageurl) as imageurl