I'm currently in the process of learning MySQL, and I've come to learning variables, however I'm having an issue accessing whats saved in my variable; I'm getting my variable contains with the following command:
SELECT
@foods := `idFood`, `price`
from
`foods`;
This seems to be working okay, and this is resulting a table, now I'm wanting to sort my table animals by the following command:
Select
*
From
`Animals`
order by `Animals`.`Food consumption` * @foods.price
where @foods.idFood = `Animals`.`FoodType`
The Animals.FoodType is holding the id of the food, that the animal is consuming.
When running this, I'm getting an error in the last part, where I'm using the variable, I've been playing around with it for quite a while without any luck.