Hi,
Thanks for the report.
The wrong result from query 1 seems to be very similar to bug MDEV-5719, reproducible on the current 10.0 tree.
Query 1 - bad results:
SELECT items_6 . * , cm1.brand AS brand1, cm2.model AS model1
FROM items_6
LEFT JOIN cars_models AS cm1 ON cm1.brandid = items_6.brand
LEFT JOIN cars_models AS cm2 ON cm2.id = items_6.model
GROUP BY items_6.id
+----+-------+-------+----------+--------+--------+
| id | brand | model | imported | brand1 | model1 |
+----+-------+-------+----------+--------+--------+
| 28 | 54 | 618 | 0 | NULL | NULL |
| 29 | 65 | 1133 | 0 | NULL | NULL |
| 30 | 123 | 0 | 0 | NULL | NULL |
+----+-------+-------+----------+--------+--------+
However, I cannot reproduce the non-unique result from query 2. Could you please confirm that you are really getting this (copy-paste from the attachment):
Query 2 - good results, but not unique by items_6.id:
SELECT DISTINCT items_6 . * , cm1.brand AS brand1, cm2.model AS model1
FROM items_6
LEFT JOIN cars_models AS cm1 ON cm1.brandid = items_6.brand
LEFT JOIN cars_models AS cm2 ON cm2.id = items_6.model
GROUP BY items_6.id
+----+-------+-------+----------+------------+--------+
| id | brand | model | imported | brand1 | model1 |
+----+-------+-------+----------+------------+--------+
| 28 | 54 | 618 | 0 | NULL | NULL |
| 29 | 65 | 1133 | 0 | Volkswagen | Touran |
| 29 | 65 | 1133 | 0 | VW | Touran |
| 30 | 123 | 0 | 0 | NULL | NULL |
+----+-------+-------+----------+------------+--------+
The result looks like something you would get without GROUP BY clause.
If you are really indeed getting it, could you please also paste the output of
EXPLAIN EXTENDED
SELECT DISTINCT items_6 . * , cm1.brand AS brand1, cm2.model AS model1
FROM items_6
LEFT JOIN cars_models AS cm1 ON cm1.brandid = items_6.brand
LEFT JOIN cars_models AS cm2 ON cm2.id = items_6.model
GROUP BY items_6.id;
SHOW WARNINGS;
and attach your cnf file .
Thanks.
I find that this query works OK: