diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index b03c4556279b1b205797243415b9baa11f22a4c9..7bced1719ebf019245e143a734a31eb829373e5b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8766,8 +8766,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
 
   if (type != Item::FIELD_ITEM &&
       item->real_item()->type() == Item::FIELD_ITEM &&
-      (item->type() != Item::REF_ITEM ||
-       !((Item_ref *) item)->depended_from))
+      !((Item_ref *) item)->depended_from)
   {
     orig_item= item;
     item= item->real_item();
@@ -13423,7 +13422,7 @@ count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
     Item::Type type=field->type();
     Item::Type real_type= field->real_item()->type();
     if (type == Item::FIELD_ITEM || (real_type == Item::FIELD_ITEM &&
-        (type != Item::REF_ITEM || !((Item_ref *) field)->depended_from)))
+        !((Item_ref *) field)->depended_from))
       param->field_count++;
     else if (real_type == Item::SUM_FUNC_ITEM)
     {