1 00:00:00,060 --> 00:00:04,870 So one more thing we're going to talk about with reading data when we're talking about crud. 2 00:00:04,890 --> 00:00:09,460 Before we move on to updating, deleting, there's one other thing which are aliases. 3 00:00:09,480 --> 00:00:11,880 These are really simple, very short video here. 4 00:00:12,030 --> 00:00:17,590 Basically, we can specify how our data should be displayed back to us. 5 00:00:17,610 --> 00:00:23,880 So what that means is rather than having cat ID, name, breed and age here, I could tell my SQL that 6 00:00:23,880 --> 00:00:31,650 instead of breed I want, I don't know, type of cat or instead of age I want years and it won't alter 7 00:00:31,650 --> 00:00:32,880 the the data itself. 8 00:00:32,880 --> 00:00:35,020 It just is how it's displayed to me. 9 00:00:35,040 --> 00:00:37,410 So let me show you a more specific example. 10 00:00:37,740 --> 00:00:40,230 Here we have using an alias. 11 00:00:40,410 --> 00:00:44,300 We're selecting the cat ID as ID. 12 00:00:44,310 --> 00:00:51,000 So rather than saying cat ID in the results, it will only say ID and then name from cats. 13 00:00:51,480 --> 00:00:57,540 Now, this is not that clear why it's useful, and that won't become clear for a little bit, because 14 00:00:57,540 --> 00:01:00,060 right now our data is very simple and straightforward. 15 00:01:00,150 --> 00:01:03,720 But once we have multiple tables and we're selecting from. 16 00:01:04,300 --> 00:01:05,190 Let me give you an example. 17 00:01:05,190 --> 00:01:10,590 Let's say we have a pet shelter where we have a cat's table and a dog's table and both of them have 18 00:01:10,590 --> 00:01:11,520 a name. 19 00:01:11,700 --> 00:01:13,890 So dogs have names, cats have names. 20 00:01:13,890 --> 00:01:19,230 And when we talk about join tables, which you'll learn about in a little bit, that's when we take 21 00:01:19,230 --> 00:01:24,570 both tables and we select from them at once and combine them and the results. 22 00:01:24,570 --> 00:01:29,220 We would have two columns with name, so we would need to figure out which one is cat name, which one 23 00:01:29,220 --> 00:01:29,910 is dog name. 24 00:01:29,910 --> 00:01:36,960 So we could use this as to relabel it so it wouldn't change the actual data or our data is the same, 25 00:01:36,960 --> 00:01:41,970 the columns are the same, but when it printed back out to us, when it spits out the data, it would 26 00:01:41,970 --> 00:01:43,140 use an alias. 27 00:01:43,410 --> 00:01:44,850 So if we try this now. 28 00:01:47,850 --> 00:01:52,560 Cat ID as ID common name from cat. 29 00:01:53,010 --> 00:01:55,440 You'll see that we get ID here. 30 00:01:55,770 --> 00:02:01,380 And just to make that clear, I did the same thing and I even put a little arrow pointing to that ID. 31 00:02:01,410 --> 00:02:03,660 It doesn't say cat ID, it says ID. 32 00:02:03,720 --> 00:02:14,280 So also just to prove this, we could do something like select name as cat name or also just to show 33 00:02:14,280 --> 00:02:16,860 you, you can use quotes to add spaces. 34 00:02:16,860 --> 00:02:25,080 So cat name like that comma will also select breed as kitty breed. 35 00:02:26,310 --> 00:02:28,380 Why not from cats? 36 00:02:29,350 --> 00:02:30,250 And there you go. 37 00:02:30,490 --> 00:02:34,360 Our new column headers here are cat name and kiddie breed. 38 00:02:34,750 --> 00:02:41,130 But of course, if we do a describe cats, you'll see nothing has changed. 39 00:02:41,140 --> 00:02:45,130 Our fields are still name and breed just when we print them out. 40 00:02:45,550 --> 00:02:47,590 So that's all there is to aliases. 41 00:02:47,830 --> 00:02:49,660 You'll see us using them later on. 42 00:02:49,660 --> 00:02:53,770 But I wanted to introduce them now so that you're not overwhelmed with a bunch of new stuff when we 43 00:02:53,770 --> 00:02:54,850 get to join tables.