# Column not found error

**URL:** <https://discourse.cakephp.org/t/column-not-found-error/9145>\
**Category:** Need Help\
**Created:** [March 21, 2021, 12:43am UTC](https://discourse.cakephp.org/t/column-not-found-error/9145 "2021-03-21T00:43:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![makamo66](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/makamo66/32/2156_2.png) [@makamo66](https://discourse.cakephp.org/u/makamo66)\
**Post date:** [March 21, 2021, 12:43am UTC](https://discourse.cakephp.org/t/column-not-found-error/9145/1 "2021-03-21T00:43:13Z")

</div>

I’m using CakePHP version 4. The add.php view in the Mealplans controller consists of several foreach statements which all look something like this:

```
<?php 
foreach ($tiles as $tile):
if ($user_id == $tile->user_id){
?>
<div id="draggable<?php echo $tile->id; ?>" class="draggable_meal">
<div class="calorie_icon"><?php echo $tile->cals_per_serving; ?> CALS</div>
<span><?php echo $tile->short_description; ?></span>
<?php 
echo $this->Form->hidden('cals_per_serving'. $tile->id, [
    'multiple' => 'true',
    'value' => $tile->cals_per_serving,
]);
} //end if
endforeach;
?>
</div>

```

I looked over my code to see if I had forgotten a foreach statement somewhere but they’re all there so the singular $tile instead of the plural $tiles should work.  
I get the error:

Column not found: 1054 Unknown column ‘Tile.cals\_per\_serving’ in ‘order clause’

It executes the following query:

`SELECT Tiles.id AS Tiles __id, Tiles.cat_id AS Tiles__ cat_id, Tiles.short_description AS Tiles __short_description, Tiles.cals_per_serving AS Tiles__ cals_per_serving, Tiles.user_id AS Tiles__user_id FROM tiles Tiles ORDER BY Tile.cals_per_serving DESC`

Note that in the ORDER BY clause it displays Tile.cals\_per\_serving and not Tiles.cals\_per\_serving with an appended s.

---

<div class="post-metadata">

**Author:** ![makamo66](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/makamo66/32/2156_2.png) [@makamo66](https://discourse.cakephp.org/u/makamo66)\
**Post date:** [March 21, 2021, 12:55am UTC](https://discourse.cakephp.org/t/column-not-found-error/9145/2 "2021-03-21T00:55:58Z")

</div>

I found the error. I had this in my MealplansController:

$this-\>set(‘tiles’, $this-\>Tiles-\>find(‘all’, [‘order’ =\> ‘Tile.cals\_per\_serving DESC’]));
