WEBVTT

00:00:00.350 --> 00:00:01.491
Welcome back!

00:00:01.671 --> 00:00:04.372
We can already read fields through
relationships.

00:00:04.552 --> 00:00:08.147
Now let us use those same paths to choose and
sort records.

00:00:09.477 --> 00:00:11.357
Continue in the same console.

00:00:11.537 --> 00:00:15.355
We will use the customers and invoices we
imported last time.

00:00:15.535 --> 00:00:20.967
If Python was closed, the download includes a
script to rebuild that temporary dataset.

00:00:22.350 --> 00:00:24.421
Let's find invoices for Florence.

00:00:24.601 --> 00:00:26.503
Use the customer city in where.

00:00:26.683 --> 00:00:30.460
Colon city is a parameter: its value is passed
separately.

00:00:30.640 --> 00:00:32.959
We only ask to return the invoice number.

00:00:34.350 --> 00:00:36.252
Let's sort invoices by city.

00:00:36.432 --> 00:00:38.505
Use the same path in order by.

00:00:38.685 --> 00:00:41.299
Without a direction, the order is ascending.

00:00:41.479 --> 00:00:43.785
Limit keeps the displayed result short.

00:00:45.183 --> 00:00:47.033
Let's show the newest rows first.

00:00:47.213 --> 00:00:50.231
From an invoice row, follow its invoice to the
date.

00:00:50.411 --> 00:00:52.262
Add DESC for descending order.

00:00:52.442 --> 00:00:55.247
These three rows belong to the latest invoice.

00:00:56.600 --> 00:00:58.428
Now start from an invoice row.

00:00:58.608 --> 00:01:02.607
To reach the customer city, go through the
invoice and then the customer.

00:01:03.937 --> 00:01:05.763
Let's find rows for Florence.

00:01:05.943 --> 00:01:08.197
The filter follows two relationships.

00:01:08.377 --> 00:01:11.823
The returned columns follow the product relation
instead.

00:01:12.003 --> 00:01:15.107
A field used in a filter need not be selected.

00:01:16.517 --> 00:01:18.311
Let's combine the conditions.

00:01:18.491 --> 00:01:22.468
Keep Florence rows from October first, newest
invoices first.

00:01:22.648 --> 00:01:24.557
City and date are parameters.

00:01:24.737 --> 00:01:27.661
Neither filtered field needs to appear in the
result.

00:01:27.841 --> 00:01:31.041
The same paths work in columns, where, and order
by.

00:01:32.371 --> 00:01:34.369
Let's close this read transaction.

00:01:34.549 --> 00:01:38.249
We only read the data; the imported records have
not changed.

00:01:39.617 --> 00:01:41.263
Thanks for following along!

00:01:41.443 --> 00:01:44.962
Use relationship fields wherever the query needs
them.

00:01:45.142 --> 00:01:50.146
Select only what you want to read, and add just
the conditions and ordering you need.
