On 06-12-11 22:48, Ian Clelland wrote:
Raw SQL:
select thing, name, vote from mydatabase_votecontext left join
mydatabase_vote on (mydatabase_vote.context_id =
mydatabase_votecontext.id <http://mydatabase_votecontext.id>) where
thing='Carrot' and user='Me'

That should return null if there is no vote. If you'd rather have zeros,
then use this:

select thing, name, ifnull(vote, 0.0) from mydatabase_votecontext left
join mydatabase_vote on (mydatabase_vote.context_id =
mydatabase_votecontext.id <http://mydatabase_votecontext.id>) where
thing='Carrot' and user='Me'

There still might be a way to do it with the ORM; but you can definitely
use raw sql for this.

Till two years ago I didn't touch an sql database for 8 years as I used zope's luxurious python object database :-) So I'm happily proven wrong in what SQL can do :-)



Reinout

--
Reinout van Rees                    http://reinout.vanrees.org/
rein...@vanrees.org             http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

--
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to