[eluser]huesoamz[/eluser]
$this->db->select('id,peso');
$this->db->where('categoria','animal');
$this->db->order_by("peso", "desc");
$this->db->limit(1);
$query = $this->get('blog');
Is correct?, but i think so that if..if more than one animal have the same "peso", i lose animals...because i only take 1..and not ALL MAX PESO.
Tks
[quote author="vitoco" date="1291166678"]if you wanna get only one id, order the rows by "peso DESC", and get the first id with LIMIT 0,1 like this :
Code:
$sql = "
SELECT
id ,
peso
FROM
blog
WHERE
categoria = ‘animal’
ORDER BY
peso DESC
LIMIT
0,1
";
Saludos[/quote]
Vitoco gracias, pero cual es la joda de usar Codeigniter si al final usamos php...la idea es usar el framework