Learn SQL Programming – 3 – Filter Queries & Get YOUR Results!

Finding Patterns in Movie Data: A Step-by-Step Guide

When working with large datasets of movie information, it can be challenging to filter and extract specific data. One common task is to find all instances of a particular title, director, or other criteria within the dataset. In this article, we will explore some techniques for filtering and extracting data from movie information, using examples from popular movies like Toy Story.

Filtering by Wildcards

------------------------

One technique for filtering data is to use wildcards, which allow us to match patterns in the data without being too specific. For example, when searching for all instances of the title "Toy Story", we might use a wildcard character such as an asterisk (*). However, this technique is not explicitly mentioned in the provided text, but rather uses a similar concept called "percent sign" wildcards. To create a match, we surround the desired pattern with a percent sign (%), which tells the database to look for any characters before or after the specified pattern.

For instance, if we want to find all movies where the title contains "Toy Story", we can use the following query: `select everything from movies where title like %toy story%`. This will return all rows where the title matches this pattern, regardless of any characters that may appear before or after it. Similarly, if we want to search for a specific director, such as John Lasseter, we can use the "like" operator with a percent sign to match the entire director's name.

Breaking Down Complex Queries

------------------------------

To create more complex queries, we can break down the desired pattern into separate components and combine them using logical operators. For example, when searching for all movies directed by John Lasseter, we might want to use both the "director" and "like" operators. We can achieve this by nesting our query as follows: `select everything from movies where director like %John Lassiter%`. By doing so, we effectively negate the entire query, returning only rows that do not match the specified pattern.

Another example is searching for all Wall-E movies. To accomplish this, we might use a similar query to the one above, but with a different desired pattern: `select everything from movies where title like %wall e%`. This will return all rows where the title contains "Wall E", regardless of any characters that may appear before or after it.

Using Logical Operators

----------------------

In addition to using wildcards and percent signs, we can also use logical operators to refine our queries. For instance, when searching for movies with a specific genre, we might want to combine multiple conditions using the "and" operator. We can achieve this by separating the individual conditions with an "and" symbol.

For example, if we want to find all Toy Story movies directed by John Lasseter and released in 1995, we could use the following query: `select everything from movies where director like %John Lassiter% and year = 1995`. By combining these two conditions using an "and" operator, we effectively narrow down our search to only include rows that match both criteria.

Conclusion

----------

Filtering and extracting data from movie information can be a complex task, but by leveraging techniques such as wildcard matching and logical operators, we can create powerful queries that refine our results. By mastering these techniques, you'll be able to extract the specific data you need, whether it's searching for all instances of a particular title or finding movies with specific criteria.

To further improve your skills, practice creating complex queries using the techniques described above. You may also want to explore other advanced filtering methods, such as using functions and aggregations to manipulate data. With time and practice, you'll become proficient in extracting valuable insights from movie information.

"WEBVTTKind: captionsLanguage: enhey guys what's up this is kazy from clever program.com welcome back to SQL part three so we're going to jump through and run through this bad boy so this is queries with constraints part two as titled up there is essentially the wear stuff but more advanced so let's go through it okay um all right so up until now hopefully you've watched part one which is important why this stuff matters um and once you wrap your mind around why this stuff matters then the learning kind of just comes from that and the enjoyment and learning comes from that as well all right find all the Toy Story movies okay so that's probably not going to be that hard I want to find everything about any movie that's Toy Story so I can try to filter it by John last but Bug's Life also has John's laer I can try to filter filter it by year but years are different could try to filter by length length is different or so well you guys think about it think about it before I say any solution how would I filter it how would I filter it so it finds a common pattern between this and the common pattern between this without being extremely specific spefic and saying something like Select Title from movies where title equal equal Toy Story and title equal equal Toy Story too so without being painfully verbose let's keep it really really simple okay and let's try to find a pattern here that will allow us to capture all of that all right so let's jump in and see okay so a lot of the times what you have to use for that is something called wild cards okay which is probably what they're going to talk about here I don't know if they use a specific word wild card but that's really what it is let's see if they use wild yep they actually do wild card card pattern matching so okay so the one that we're probably looking for is something like an asterisk which they're not showing here I think I can say like okay so I can use this word like all right check it out this is going to be really cool what do I have to select I have to select only the title since we have to find all the Toy Story titles we are going to do select star for now from movies where title like and here they do wild card matching so if you do the percent sign and you put anything in between it it'll just look for that so for example at is called inside sensitive case uh matching so here at or attic or bats or cat anything has at in it either at the end or at the beginning or in the middle okay so we title like um percent toy um story because we're looking for Toy Story 1 Toy Story 2 Toy Story 3 so we're going to say just look for this and then that's it so it almost reads like English select everything from movies where the title is like Toy Story it's like right um but generally how you'll write it is just break it down on separate lines so it's easy to kind of Reason through it and read through it okay let's reset let's try the second one you try it and then I'm going to do it as well so then you follow along and look at my solution okay no cheat in you don't deserve to cheat unless you know how to do it so pause please then actively learn and then you can come and see the solutions it's a good idea to learn like that find all the movies directed by John Lassiter so how are we going to do that think about it okay pause if you got it uh okay good I'm going to go through it I'm just going to kind of speak it and then I'm going to like format it so okay select all the movies so I'm going to say select all the movies from movies where director and I can say like and I'm going to say John Lasseter okay so it selected all the movies where that's the director perfect let's reset again find all the movies in director not directed by John Lasser okay so select here's the hack I'm GNA do for this one from movies where director like John Lassiter okay and check out the hack and just negate the whole thing and then it gives you the opposite that's it boom done all right find all the Wall E movies so for example you might have Wall G or Wall E or yeah that's it so I think I can do it the same way um I can say select everything from you know and then go down select everything from movies where movie like or we're sorry title like wall let's do percent like that okay um and I don't need the percent behind that I can just say wall and then whatever matches whatever random stuff afterwards is fine I can also do this and then do the percent sign here okay all of those work okay guys we are done with exercise three great job so far keep trying to do it on your own and then also then check in with the video because I'll cover a lot of the peripheral stuff that goes around it for example I'll do some right now um here you have like if not like you have uh in and not in so for example how I would use in here is I can say we title in Wall E comma wall G that also works okay so that's an example okay guys thank you for watching awesome I'll see you in part four I think that's what it should be and we're going to cover more stuff so this is it for this video and I'll see you in the next videohey guys what's up this is kazy from clever program.com welcome back to SQL part three so we're going to jump through and run through this bad boy so this is queries with constraints part two as titled up there is essentially the wear stuff but more advanced so let's go through it okay um all right so up until now hopefully you've watched part one which is important why this stuff matters um and once you wrap your mind around why this stuff matters then the learning kind of just comes from that and the enjoyment and learning comes from that as well all right find all the Toy Story movies okay so that's probably not going to be that hard I want to find everything about any movie that's Toy Story so I can try to filter it by John last but Bug's Life also has John's laer I can try to filter filter it by year but years are different could try to filter by length length is different or so well you guys think about it think about it before I say any solution how would I filter it how would I filter it so it finds a common pattern between this and the common pattern between this without being extremely specific spefic and saying something like Select Title from movies where title equal equal Toy Story and title equal equal Toy Story too so without being painfully verbose let's keep it really really simple okay and let's try to find a pattern here that will allow us to capture all of that all right so let's jump in and see okay so a lot of the times what you have to use for that is something called wild cards okay which is probably what they're going to talk about here I don't know if they use a specific word wild card but that's really what it is let's see if they use wild yep they actually do wild card card pattern matching so okay so the one that we're probably looking for is something like an asterisk which they're not showing here I think I can say like okay so I can use this word like all right check it out this is going to be really cool what do I have to select I have to select only the title since we have to find all the Toy Story titles we are going to do select star for now from movies where title like and here they do wild card matching so if you do the percent sign and you put anything in between it it'll just look for that so for example at is called inside sensitive case uh matching so here at or attic or bats or cat anything has at in it either at the end or at the beginning or in the middle okay so we title like um percent toy um story because we're looking for Toy Story 1 Toy Story 2 Toy Story 3 so we're going to say just look for this and then that's it so it almost reads like English select everything from movies where the title is like Toy Story it's like right um but generally how you'll write it is just break it down on separate lines so it's easy to kind of Reason through it and read through it okay let's reset let's try the second one you try it and then I'm going to do it as well so then you follow along and look at my solution okay no cheat in you don't deserve to cheat unless you know how to do it so pause please then actively learn and then you can come and see the solutions it's a good idea to learn like that find all the movies directed by John Lassiter so how are we going to do that think about it okay pause if you got it uh okay good I'm going to go through it I'm just going to kind of speak it and then I'm going to like format it so okay select all the movies so I'm going to say select all the movies from movies where director and I can say like and I'm going to say John Lasseter okay so it selected all the movies where that's the director perfect let's reset again find all the movies in director not directed by John Lasser okay so select here's the hack I'm GNA do for this one from movies where director like John Lassiter okay and check out the hack and just negate the whole thing and then it gives you the opposite that's it boom done all right find all the Wall E movies so for example you might have Wall G or Wall E or yeah that's it so I think I can do it the same way um I can say select everything from you know and then go down select everything from movies where movie like or we're sorry title like wall let's do percent like that okay um and I don't need the percent behind that I can just say wall and then whatever matches whatever random stuff afterwards is fine I can also do this and then do the percent sign here okay all of those work okay guys we are done with exercise three great job so far keep trying to do it on your own and then also then check in with the video because I'll cover a lot of the peripheral stuff that goes around it for example I'll do some right now um here you have like if not like you have uh in and not in so for example how I would use in here is I can say we title in Wall E comma wall G that also works okay so that's an example okay guys thank you for watching awesome I'll see you in part four I think that's what it should be and we're going to cover more stuff so this is it for this video and I'll see you in the next videohey guys what's up this is kazy from clever program.com welcome back to SQL part three so we're going to jump through and run through this bad boy so this is queries with constraints part two as titled up there is essentially the wear stuff but more advanced so let's go through it okay um all right so up until now hopefully you've watched part one which is important why this stuff matters um and once you wrap your mind around why this stuff matters then the learning kind of just comes from that and the enjoyment and learning comes from that as well all right find all the Toy Story movies okay so that's probably not going to be that hard I want to find everything about any movie that's Toy Story so I can try to filter it by John last but Bug's Life also has John's laer I can try to filter filter it by year but years are different could try to filter by length length is different or so well you guys think about it think about it before I say any solution how would I filter it how would I filter it so it finds a common pattern between this and the common pattern between this without being extremely specific spefic and saying something like Select Title from movies where title equal equal Toy Story and title equal equal Toy Story too so without being painfully verbose let's keep it really really simple okay and let's try to find a pattern here that will allow us to capture all of that all right so let's jump in and see okay so a lot of the times what you have to use for that is something called wild cards okay which is probably what they're going to talk about here I don't know if they use a specific word wild card but that's really what it is let's see if they use wild yep they actually do wild card card pattern matching so okay so the one that we're probably looking for is something like an asterisk which they're not showing here I think I can say like okay so I can use this word like all right check it out this is going to be really cool what do I have to select I have to select only the title since we have to find all the Toy Story titles we are going to do select star for now from movies where title like and here they do wild card matching so if you do the percent sign and you put anything in between it it'll just look for that so for example at is called inside sensitive case uh matching so here at or attic or bats or cat anything has at in it either at the end or at the beginning or in the middle okay so we title like um percent toy um story because we're looking for Toy Story 1 Toy Story 2 Toy Story 3 so we're going to say just look for this and then that's it so it almost reads like English select everything from movies where the title is like Toy Story it's like right um but generally how you'll write it is just break it down on separate lines so it's easy to kind of Reason through it and read through it okay let's reset let's try the second one you try it and then I'm going to do it as well so then you follow along and look at my solution okay no cheat in you don't deserve to cheat unless you know how to do it so pause please then actively learn and then you can come and see the solutions it's a good idea to learn like that find all the movies directed by John Lassiter so how are we going to do that think about it okay pause if you got it uh okay good I'm going to go through it I'm just going to kind of speak it and then I'm going to like format it so okay select all the movies so I'm going to say select all the movies from movies where director and I can say like and I'm going to say John Lasseter okay so it selected all the movies where that's the director perfect let's reset again find all the movies in director not directed by John Lasser okay so select here's the hack I'm GNA do for this one from movies where director like John Lassiter okay and check out the hack and just negate the whole thing and then it gives you the opposite that's it boom done all right find all the Wall E movies so for example you might have Wall G or Wall E or yeah that's it so I think I can do it the same way um I can say select everything from you know and then go down select everything from movies where movie like or we're sorry title like wall let's do percent like that okay um and I don't need the percent behind that I can just say wall and then whatever matches whatever random stuff afterwards is fine I can also do this and then do the percent sign here okay all of those work okay guys we are done with exercise three great job so far keep trying to do it on your own and then also then check in with the video because I'll cover a lot of the peripheral stuff that goes around it for example I'll do some right now um here you have like if not like you have uh in and not in so for example how I would use in here is I can say we title in Wall E comma wall G that also works okay so that's an example okay guys thank you for watching awesome I'll see you in part four I think that's what it should be and we're going to cover more stuff so this is it for this video and I'll see you in the next video\n"