Activa JavaScript para disfrutar de los vídeos de la Mediateca.
Querries - Contenido educativo
Ajuste de pantallaEl ajuste de pantalla se aprecia al ver el vídeo en pantalla completa. Elige la presentación que más te guste:
Well, this time we are going to talk about database, but queries.
00:00:00
One important thing about queries is that you can have queries of different types.
00:00:07
You can have queries that do something, such as delete some records in a table, or update
00:00:13
some dates in a table, some registers and records, but in this level, the only type
00:00:23
of queries that we are going to study is selection queries.
00:00:34
In any case, selection queries can be also complicated.
00:00:41
First of all, as I click in Queries, we have three possibilities to create a query.
00:00:45
One is in the side-by view, another is using a system, and finally using SQL.
00:00:55
What is SQL?
00:01:04
Well, SQL is a language that lets you to manage all the database.
00:01:05
You have a database, you can program this database using this type of language, but
00:01:16
But obviously it's a programming language so it's complicated, it's not easy.
00:01:22
And in this level it's not necessary that you reach this level.
00:01:27
You can do it in the first year of your degree or even in the university, but not at this
00:01:32
level.
00:01:41
But it's enough that you know that they exist, it exists, it's enough now.
00:01:42
Well in any case we are going to begin using the assistant.
00:01:50
So click in the assistant, and here you have, it's a formular indeed, it's very easy to
00:01:55
use.
00:02:05
Firstly, what you must choose is which table you are going to do the query.
00:02:06
For example, clients.
00:02:13
So you have all the fields that client has.
00:02:15
You must choose, you can choose all of them if you want, or just a few of them, it's your
00:02:20
choice obviously.
00:02:29
Well, in this case, for me, it's enough with a client code, Enterprise, for example, Townhouse
00:02:30
City.
00:02:45
Then click on next. Here you can order, taking into consideration the order in one file, for example, this file.
00:02:49
If you order in this file, the record has been ordered in this file.
00:03:05
or ascending or descending, in ascending or descending mode.
00:03:16
Then, well, sometimes, very often, we usually add a criteria to do the selection of the record.
00:03:21
So, for example, the first thing that you should do is select in which file do you want to add a criteria.
00:03:33
For example, town.
00:03:45
And then here you can add a value for this town, for this field,
00:03:50
that lets you to create the selection, for example, Madrid.
00:03:59
Come finish.
00:04:04
Finish your query.
00:04:15
And here is the query, just only two records.
00:04:18
But what happened?
00:04:26
It's more or less the same as you use a filter to do this.
00:04:27
It's not so important, it's not, indeed it's not, it's nothing that the query is added
00:04:32
to what we have already can do.
00:04:41
Well we are going to edit it and you can see the design view.
00:04:45
What happens is that if you look at the design view you can add more than one criteria.
00:04:55
And you can also add this criteria using an or all operation, logical operation.
00:05:03
So it is true that with this first query you haven't done so much, but it is also true
00:05:14
that it is a very very easy query.
00:05:24
So what I want to prove, for example, if I want to do a query in which I have involved
00:05:29
More than one table is what you must do because if you use the assistant, it's not possible.
00:05:40
There's only one table.
00:05:46
You can join or you can use more than one table.
00:05:48
So I have to use another type of query also, and obviously, what happened?
00:05:52
Well, we are going to use design view query.
00:06:01
view query as you can see you have all the tables so for example you can add it
00:06:07
these two tables and as you can see here you can add these two tables you can do
00:06:16
a query with two tables if they are related. So maybe it's important to
00:06:48
revise the context of relations before doing any query in which you
00:07:02
involve more than one table. So we are going to leave this query and we are
00:07:11
going to go back to tables. Well, if you click in tools you have relationships.
00:07:21
Well, here in relationships you can see that we have a line that correspond the field
00:07:29
that has in common to table. For example, table clients and table pedidos have in
00:07:41
common a client code and table pedidos and table products have in common a client code and you have
00:07:48
a line what does it mean well we are going to explain it I'm going to delete firstly and I'm
00:07:59
going to explain what is this from the beginning what happened is you have tables that have some
00:08:08
field in common you can relate it this table. It means that if you have
00:08:25
one table you can know the fields that correspond in other tables and are
00:08:38
more or less the same. So for example you are in tables and now I'm going to
00:08:45
select in the rubber tools. Tools, relationship. Clients, this one, and also
00:08:57
products. So we have the three tables. What happened? Clients and this other
00:09:11
table have one field in common which is this one, client code. So I can
00:09:52
You can create a new relation between clients and this other table in client code.
00:10:08
This type of relationship means that each register can have a relationship with so many
00:10:34
registers in the other table.
00:10:48
You can also create another relationship between this table, which is pedidos and products.
00:10:51
What is products?
00:11:08
In products you have the product code, and in pedidos you have the product code.
00:11:09
So you also have the relation between these tables.
00:11:22
So now we have relationships between different tables and it lets you to create missing queries
00:11:28
is the advantage because obviously it doesn't matter that you have to create any relationship.
00:11:38
If you open clients, you have the same.
00:11:51
If it were access, you can see the difference between the tables in which you have any relationship
00:12:06
and you have relationship.
00:12:15
But in this way, sorry, but it's not possible to show anything that shows the relationship.
00:12:17
You can't see the relationship, it's nothing, it's any action in which you can show it.
00:12:25
But it is true that when you create a query in DesignVue and you, for example, select
00:12:33
these two tables, they show you the relationship between these two tables.
00:12:46
So now, we are going to choose this code, also for example the product code, also for
00:12:57
example the price, and maybe for example this one.
00:13:23
If you don't give any value to do the selection, you have a selection indeed, because you select
00:13:42
some fields and you miss two tables.
00:13:51
So even if you added any criteria or not, you have done a query selection.
00:13:55
And the result is this.
00:14:14
But obviously, what is interesting, if you added some criteria, for example, we are going
00:14:19
to add it that just only the register in which the price is more than or less than 15.
00:14:27
So we edit this one, and here our criteria is less than 15, yes?
00:14:44
So if I save this as selection tool, the result is this.
00:14:58
So you have selected just only the registers in which the price is less than 15.
00:15:16
You for example now can do a different selection because you can select that at the same time
00:15:25
this price is less than 15 and you have sent it.
00:15:36
So in this case, if here in the same file you added null, because this field is binariful,
00:15:44
so it can only have two values, null or not null, null means that you have send it.
00:16:08
So now I can save as query three, and you have the selection.
00:16:20
In this case, the condition of the value is at the same time.
00:16:40
If you don't do it in this way, what happens is it's the same as this, sorry.
00:16:48
So it's better if you do the 10S one, I don't know, maybe it's not good, yes it's good.
00:17:28
So it's the same, it's the same as do in this way or do in another way, in this other way.
00:17:38
Instead here, u is empty or null, it means that this condition of this condition.
00:17:53
So if you save as selection 3, again, what you save is more or less the same as selection
00:18:14
2.
00:18:37
This and this are the same.
00:18:39
So as a consequence of this, but this is different, sorry, this query is different, yes?
00:18:49
So I think it's clear that the differences between one of those.
00:19:27
For example, another one, clients and products, no products, no.
00:19:34
So for example, client code, town, for example here, town, enterprise, units, and send it,
00:20:02
We can, for example, choose less than 10, and locate it, for example, Madrid.
00:20:32
If you do it this way, both criteria must be at the same time.
00:20:58
So, click in 45, and there's nothing.
00:21:15
Nothing.
00:21:26
Why?
00:21:27
possible? Well, maybe we're going to edit it. We're going to delete this one. So you have this register
00:21:28
less units than 10 and there is anything of these from Madrid, so it's logical.
00:22:09
We're going to sell us for example Alicante or Seville or Seville. Alicante. La Coruña.
00:22:18
We're going to select La Coruña.
00:22:25
It's here.
00:22:34
You select.
00:22:35
The result of this query is this.
00:22:54
It's okay.
00:23:00
If you just choose with OR, you have the same, the same of the other query.
00:23:02
So that's the reason why sometimes it's not necessary OR.
00:23:12
Or it's not a good logical operation to create a good selection query.
00:23:18
But yes, because it's another filter, it's about a filter.
00:23:29
Well it's more or less what you must do about queries.
00:23:36
- Idioma/s:
- Autor/es:
- Isabel Lafuente Reboredo
- Subido por:
- Isabel L.
- Licencia:
- Reconocimiento - No comercial
- Visualizaciones:
- 35
- Fecha:
- 3 de diciembre de 2020 - 18:29
- Visibilidad:
- Público
- Centro:
- CP INF-PRI-SEC EL CANTIZAL
- Duración:
- 23′ 49″
- Relación de aspecto:
- 16:10 El estándar usado por los portátiles de 15,4" y algunos otros, es ancho como el 16:9.
- Resolución:
- 1440x900 píxeles
- Tamaño:
- 39.39 MBytes