On 2015-02-27 06:12, Josh Smeaton wrote:
> The concept of batched SELECT statements doesn't really exist in
> SQL, unless the relations you're selecting have identical column
> types. Example:
> 
> SELECT name, age_in_years FROM person
> UNION ALL
> SELECT item_name, quantity FROM item;
> 
> The UNION here means combine the results of each query into the one
> result set. A query like this probably isn't useful though, because
> you have no way of knowing which row belongs to which relation (or
> model)

For the record, I've done this with

  SELECT 'Person' AS description, name, age_in_years FROM person
  UNION ALL
  SELECT 'Item', item_name, quantity FROM item;

which allows me to distinguish them while gaining everything in one
query/result-set.

-tkc



-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/20150227112523.487da135%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.

Reply via email to