On 8/10/15 5:30 PM, Eric Miller wrote:
Well, I meant that I need to know how to do this in sqlalchemy.
assuming ORM, joins are first introduced at
http://docs.sqlalchemy.org/en/rel_1_0/orm/tutorial.html#querying-with-joins,
it would look like:
session.query(Table1).join(Table2).order_by(Table2.name)
On Monday, August 10, 2015 at 5:17:34 PM UTC-4, Michael Bayer wrote:
On 8/10/15 3:42 PM, Eric Miller wrote:
I have a table that needs to be sorted alphabetically by names
that aren't actually contained in the table *in sqlalchemy*. Only
codes representing the names are in the table. Like so...
Table 1:
|row code month value 1 A 201501 50 2 Z 201501 100 3 CO 201501 200
4 VA 201502 300 5 C 201502 300 |
Table 2:
|row code name 1 A Apple 2 C Cascade 3 CO Colorado 4 VA Virginia |
I need to sort *Table 1* the following:
* month
* name (found in Table 2)
What is the best technique to achieve these sorting results when
the sorting occurs on value not inherent in the table. I can't
send the joined product of Table 1 and Table 2. Although, I can
join them temporarily and remove the 'name' column if needed.
you need to produce rows that are a composite of table1 and
table2, so that a single row contains both the columns you want to
receive as well as the columns you intend to sort by. You do this
using JOIN. SQL would be:
SELECT table1.* FROM table1 JOIN table2 ON table1.code=table2.code
ORDER BY table2.name <http://table2.name>
--
You received this message because you are subscribed to the
Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected] <javascript:>.
To post to this group, send email to [email protected]
<javascript:>.
Visit this group at http://groups.google.com/group/sqlalchemy
<http://groups.google.com/group/sqlalchemy>.
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.