Re: Custom SQL with a variable issue.

2009-05-05 Thread MikeL
On May 4, 11:31 am, pbzRPA wrote: > Hi, > > Could you provide the code of your model and why you would want to use > a custom sql instead of the django model object. > > Regards > Pbzrpa class Stats(models.Model) user = models.ForeignKey(User) variant = models.ForeignKey(PlazaGam

Re: Custom SQL with a variable issue.

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 10:31 -0700, MikeL wrote: > I figured it out. I had to run cursor.execute for the SET and the > SELECT line and it managed to remember the @row being 0 between them. > Though it would be nice if a django solution exists. You found the Django solution already: use cursor.exec

Re: Custom SQL with a variable issue.

2009-05-04 Thread Malcolm Tredinnick
On Mon, 2009-05-04 at 11:31 -0700, pbzRPA wrote: > Hi, > > Could you provide the code of your model and why you would want to use > a custom sql instead of the django model object. For the type of query that Mike is asking about, custom SQL is a reasonable solution. Django cannot really provide

Re: Custom SQL with a variable issue.

2009-05-04 Thread pbzRPA
Hi, Could you provide the code of your model and why you would want to use a custom sql instead of the django model object. Regards Pbzrpa --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To pos

Re: Custom SQL with a variable issue.

2009-05-04 Thread MikeL
I figured it out. I had to run cursor.execute for the SET and the SELECT line and it managed to remember the @row being 0 between them. Though it would be nice if a django solution exists. Regardless, MikeL On May 4, 10:15 am, MikeL wrote: > I'm trying to make a query which lists the top 5 rate

Custom SQL with a variable issue.

2009-05-04 Thread MikeL
I'm trying to make a query which lists the top 5 rated users along with the rating (and rank) of the current user. The top 5 was easy, but I'm having a problem getting the rank of the current user. I know the sql needed to calculate the rank, but it requires a variable. SET @row=0; SELECT rank fr