diff --git a/Docs/manual.texi b/Docs/manual.texi
index 829c1becacbfed1c9735e3ddf8dd5549073375ac..2bc8d3ae5ac6d1267aed0387fe23b09a751c48bc 100644
--- a/Docs/manual.texi
+++ b/Docs/manual.texi
@@ -39222,6 +39222,9 @@ though, so Version 3.23 is not released as a stable version yet.
 @appendixsubsec Changes in release 3.23.29
 @itemize @bullet
 @item
+Fixed bug when doing a @code{SELECT DISTINCT ... table1 LEFT JOIN
+table2..] when table2 was empty.
+@item
 Added @code{--abort-slave-event-count} and
 @code{--disconnect-slave-event-count} options to @code{mysqld} for
 debugging and testing of replication
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 8856d31645ce35f290b6d91525954b09364887c2..31fc3f28099fc4a01e651a6cff3722f7c4b552c5 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5218,8 +5218,10 @@ remove_duplicates(JOIN *join, TABLE *entry,List<Item> &fields)
   List_iterator<Item> it(fields);
   Item *item;
   while ((item=it++))
-    if (item->tmp_table_field())
+  {
+    if (item->tmp_table_field() && ! item->const_item())
       field_count++;
+  }
 
   if (!field_count)
   {						// only const items