Re: Mysql Quires using raw()

2010-11-11 Thread Jagdeep Singh Malhi
> >>> from django.db.models import Max > >>> Client.objects.aggregate(maxid=Max('id')) > > {'maxid': 2L} > > And you'll get a dictionary with the value you want as a result. > > [1]:http://docs.djangoproject.com/en/1.1/topics/db/aggregation/ Thanks for link, problem solve. -- You received thi

Re: Mysql Quires using raw()

2010-11-11 Thread Łukasz Rekucki
On 11 November 2010 09:17, Jagdeep Singh Malhi wrote: > > now I also try  another method to get max(id) > >    from django.db import connection >    cursor = connection.cursor() >    cursor.execute('SELECT max(id) FROM automation_client') >    maxid = cursor.fetchone() > > output is : > (2L,) > >

Re: Mysql Quires using raw()

2010-11-11 Thread Jani Tiainen
On Tuesday 09 November 2010 12:25:30 Jagdeep Singh Malhi wrote: > hi > I am facing problem with raw() mysql quiers > for example : > maxid = Client.objects.raw('SELECT Max(id) FROM client') > > print maxid > > output is :- > > > I am using Django 1.2 version. > where I am wrong? Nowhere. Outpu

Re: Mysql Quires using raw()

2010-11-11 Thread Jagdeep Singh Malhi
now I also try another method to get max(id) from django.db import connection cursor = connection.cursor() cursor.execute('SELECT max(id) FROM automation_client') maxid = cursor.fetchone() output is : (2L,) but i want only 2 not any other character. Is any other method to get

Re: Mysql Quires using raw()

2010-11-11 Thread Jagdeep Singh Malhi
> Nowhere. Output is correct and as documented - you get back *RawQuerySet*. Not > a single value. > > So you have to do something like: > > maxid = Client.objects.raw('SELECT MAX(job_no) as max_job_no FROM > CLIENT').values_list('max_job_no', flat=True)[0] facing this error AttributeError: 'RawQ

Re: Mysql Quires using raw()

2010-11-09 Thread Jani Tiainen
On Tuesday 09 November 2010 12:25:30 Jagdeep Singh Malhi wrote: > hi > I am facing problem with raw() mysql quiers > for example : > maxid = Client.objects.raw('SELECT Max(id) FROM client') > > print maxid > > output is :- > > > I am using Django 1.2 version. > where I am wrong? Nowhere. Outpu