WEBVTT

00:00.090 --> 00:05.250
So one more thing we're going to talk about with reading data when we're talking about crud before we

00:05.250 --> 00:09.460
move on to updating and deleting there's one other thing which are aliases.

00:09.570 --> 00:11.940
These are really simple very short video here.

00:12.180 --> 00:17.540
Basically we can specify how our data should be displayed back to us.

00:17.730 --> 00:23.610
So what that means is rather than having cat ID name breed and age here I could tell my as well that

00:23.970 --> 00:28.400
instead of breed I want I don't know type of cat.

00:28.410 --> 00:32.850
Or instead of age I want years and it won't alter the data itself.

00:32.850 --> 00:34.990
It just is how it's displayed to me.

00:35.220 --> 00:37.550
So let me show you a more specific example.

00:37.830 --> 00:40.280
Here we have using an alias.

00:40.590 --> 00:49.170
We're selecting the cat ID as ID so rather than saying cat ID in the results it will only say id and

00:49.170 --> 00:51.580
then name from cats.

00:51.600 --> 00:57.690
Now this is not that clear why it's useful and that won't become clear for a little bit because right

00:57.690 --> 01:00.050
now our data is very simple and straightforward.

01:00.300 --> 01:03.810
But once we have multiple tables and we're selecting from.

01:04.080 --> 01:08.580
But let me give you an example let's say we have a pet shelter where we have a cat table and a dog table

01:09.060 --> 01:11.750
and both of them have a name.

01:11.820 --> 01:12.840
So dogs have names.

01:12.840 --> 01:13.960
Cats have names.

01:14.130 --> 01:19.590
And when we talk about join tables which you'll learn about in a little bit that's when we take both

01:19.710 --> 01:26.100
tables and we select from them at once and combine them and the results we would have two columns with

01:26.100 --> 01:27.150
name.

01:27.150 --> 01:29.920
So we would need to figure out which one is cat name which one is dog meat.

01:29.970 --> 01:35.220
So we could use this as to label it so it wouldn't change the actual data.

01:35.280 --> 01:40.470
Ours our data is the same the columns are the same but when printed back out to us when it spits out

01:40.470 --> 01:43.560
the data it would use an alias.

01:43.560 --> 01:44.580
So if we try this now

01:47.750 --> 01:55.550
Cat ID as ID a common name from cats you'll see that we get ID here.

01:55.930 --> 02:01.430
And just to make that clear I did the same thing and I even put a little arrow pointing to that ID.

02:01.480 --> 02:03.890
It doesn't say cat I.D. It says ID.

02:03.910 --> 02:14.410
So also just to prove this we could do something like select name as cat name or Also just to show you

02:14.410 --> 02:16.820
you can use quotes to add spaces.

02:16.990 --> 02:26.350
So cat name like the comma will also select breed as Kitty breed.

02:26.350 --> 02:28.520
Why not from cats.

02:29.360 --> 02:30.430
And there you go.

02:30.580 --> 02:34.550
Our new column headers here are cat name and Kitty breed.

02:34.890 --> 02:41.190
But of course if we do describe cats you'll see nothing has changed.

02:41.200 --> 02:43.840
Our fields are still name and breed.

02:43.840 --> 02:49.650
Just when we print them out so that's all there is to alias's you'll see us using them later on.

02:49.870 --> 02:53.360
But I want to introduce them now so that you're not overwhelmed with a bunch of new stuff.

02:53.500 --> 02:54.610
When we get to join tables.
