On 3/24/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> coulix wrote:
> > Hello,
> > I was trying to play with custom query but i didnt manage to get it
> > working,
>
> I too could not get the custom query from the API reference working:
>
> polls.get_list(
>     select={
>         'choice_count': 'SELECT COUNT(*) FROM choices WHERE poll_id =
> polls.id'
>     }
> )
>
> Trying the query in a 0.91/MySQL installation on both Mac OS X and an
> NT box generated the same error. (Since there's a single quote, a
> backtick and a double quote in the error message, it seems something is
> wonky in the behind-the-scenes query quoting.)

There's a closing parenthesis as well (after polls.id):

> ProgrammingError: (1064, "You have an error in your SQL syntax.  Check
> the manual that corresponds to your MySQL server version for the right
> syntax to use near 'SELECT COUNT(*) FROM choices WHERE poll_id =
> polls.id) AS `choi")

But then, you are putting polls.id in your query, and you are not
selecting from a polls table, so something is not right there. Maybe
you need a JOIN, or is polls.id supposed to be a Python attribute
reference? If so, it can't go directly in SQL.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to