Welcome Guest, Not a member yet? Register   Sign In
Order by date not working
#1

[eluser]chubbypama[/eluser]
Hi there. I would like to write a query that returns the latest record in a table. Actually, it's a little more complicated than that but right now, i can't seem to get the basic order by working.

Here's what i have:

Code:
$this->db->order_by('updated','desc');
$this->db->group_by('ip);

but it returns the first record.

I tried changing my code to :
Code:
$this->db->order_by(DATE_FORMAT('%Y-%m-%d','updated'),'desc');

but the syntax is incorrect.
the sql that generates is SELECT * FROM MYTABLE GROUP BY 'ip' ORDER BY 'desc

any help would be appreciated.
thanks.
#2

[eluser]sanir[/eluser]
why you add group by while there is no aggregation function use in query/
#3

[eluser]chubbypama[/eluser]
doh! thanks.




Theme © iAndrew 2016 - Forum software by © MyBB