Learning Library

← Back to Library

SQL Query Anatomy Explained

Key Points

  • All major relational databases—from enterprise systems like Oracle, IBM DB2, and Microsoft SQL Server to developer‑friendly options like MySQL, PostgreSQL, and embedded SQLite—share a common language: SQL (Structured Query Language).
  • SQL was originally created in 1970 and became an ANSI standard in 1986, establishing a portable query language that works across virtually any SQL‑compliant database.
  • The core of any SQL statement consists of an action keyword (e.g., SELECT, INSERT, UPDATE), a list of columns (or * for all columns), a FROM clause identifying the table, and an optional WHERE clause to filter rows.
  • Because SQL abstracts data as rows and columns in tables, learning it once lets you manipulate, retrieve, and manage data in any relational database without relearning each product’s proprietary syntax.
  • Mastering these basic query components provides a foundation for more advanced operations and scaling, enabling developers to become proficient SQL users quickly.

Full Transcript

# SQL Query Anatomy Explained **Source:** [https://www.youtube.com/watch?v=et1n7-UxI2M](https://www.youtube.com/watch?v=et1n7-UxI2M) **Duration:** 00:08:53 ## Summary - All major relational databases—from enterprise systems like Oracle, IBM DB2, and Microsoft SQL Server to developer‑friendly options like MySQL, PostgreSQL, and embedded SQLite—share a common language: SQL (Structured Query Language). - SQL was originally created in 1970 and became an ANSI standard in 1986, establishing a portable query language that works across virtually any SQL‑compliant database. - The core of any SQL statement consists of an action keyword (e.g., SELECT, INSERT, UPDATE), a list of columns (or * for all columns), a FROM clause identifying the table, and an optional WHERE clause to filter rows. - Because SQL abstracts data as rows and columns in tables, learning it once lets you manipulate, retrieve, and manage data in any relational database without relearning each product’s proprietary syntax. - Mastering these basic query components provides a foundation for more advanced operations and scaling, enabling developers to become proficient SQL users quickly. ## Sections - [00:00:00](https://www.youtube.com/watch?v=et1n7-UxI2M&t=0s) **SQL: The Universal Database Language** - The speaker explains that Oracle, DB2, SQL Server, MySQL, PostgreSQL, and SQLite all share SQL, outlining its 1970 invention, 1986 ANSI standardization, and its portable table‑based query structure. ## Full Transcript
0:00all right let's go it's time for senior 0:02expan Pop Quiz what do the Enterprise 0:05databases like Oracle and IBM db2 and 0:09Microsoft SQL Server developer databases 0:12like MySQL and postgress and even 0:15embedded databases like sqlite all have 0:18in common well you're probably starting 0:20to Google right now but let me just kill 0:23the suspense here they have what's known 0:25as 0:26SQL in common SQL stands for structured 0:31query language now a couple of quick 0:34facts about this particular language 0:37which is used to process and uh deal 0:41with storing of database uh storing of 0:43data inside of relational databases the 0:45first it was 0:47invented do a little eye there invented 0:51in 1970 that is almost 54 years ago many 0:57many moons before even I was even born 1:00and then roughly around 14 years later 1:02it was made as a 1:04standard by the ansy organization in 1:101986 now the big part about that is that 1:13it is a standard that everybody learns 1:16as a technology here and the cool thing 1:19about this is they made a way for all 1:22these databases to function by being 1:25able to store data in a table format so 1:28you're going to have a a series of rows 1:31and columns and that is how you store 1:34your data now the the second part about 1:37that is the big part about SQL is how 1:40you compose these queries and so because 1:43it's so portable once you learn this 1:45language one time you can use it across 1:48almost every relational database that 1:50actually functions off SQL off this 1:53standard that's there so let's break 1:55down the anatomy of aqu query and then 1:57I'll give you some tips on how to kind 1:59of get started in your learning and 2:01really become an expert overnight all 2:03right the first is you're going to have 2:04the actual action of what you want to do 2:08so it's going to start out with the 2:10insert the 2:14update okay of whatever you want to do 2:18and depending on what you're kind of 2:19going from or a select if you want to 2:21read data 2:22out all right and then you're G to have 2:25either a wow card which is saying give 2:27me everything from that particular 2:30uh column that I have that row that I 2:32have or you can specify the actual 2:35column names that you want so we'll just 2:37say 2:38C1 C2 you get the gist there next you're 2:43going to say the from statement so you 2:45have to tell it all right I want data I 2:47want to do this action I want these 2:49particular columns but where do I want 2:52to do it on well it'll be the database 2:56name and the actual table 3:00that I want to do it from now the last 3:02part of that is the where you have some 3:08condition that occurs and that can be a 3:10filter based upon like I'll do a a 3:14simple one like where uh ID 3:18equals uh one a particular number or you 3:21can do where some other condition price 3:23is greater than 50 uh whatever you're 3:26doing is really about being able to 3:28select the proper data out of your uh 3:31particular database now so that you 3:34could do all these queries they're very 3:35easy to do and then you're going to have 3:37ways where you can actually escalate 3:39this because these databases do hold 3:42quite a large amount of information are 3:44very very capable and in their nature 3:47they always scale kind of vertically 3:49Naturally by adding more CPU uh adding 3:52more memory adding more storage to 3:55fulfill the needs that you need uh from 3:57that particular um project that you're 4:00working on but let's talk about a couple 4:02other ways um that you can go now this 4:04is a very simple query but it can get 4:07very complicated and very complex that 4:09you can read any kind of guide on SQL 4:12online and it'll take you from this 4:14example to where you can actually write 4:16two of these statements and join data 4:18together from different tables um it 4:21just gets very exciting to to work with 4:24but as your queries get more more more 4:27complex you're going to want to go go 4:29across two two different things that I 4:30want to discuss that should be top of 4:32mind when you want to do the first is 4:35what we like to call a 4:40view now R viw is a way to kind of 4:43abstract away the complexity of your 4:46particular query where you can kind of 4:47Alias it or just simplify it so it's 4:50easier to read um it's easier to execute 4:54and it can be fine-tuned uh from there 4:57uh to work so in this particular one if 5:00I was doing let's say we had books and 5:02authors books in a table we could say um 5:06select my favorite books as the name of 5:09the view but it actually has this 5:11particular context underneath the actual 5:14query all right uh so next on other 5:17Enterprise when you start to get to that 5:18Enterprise tier that I mentioned before 5:20they'll have functionality called store 5:24procedures all right so let's do the 5:27store procedures so store procedures 5:32we're do it called stor proc and I've 5:34worked with this a lot especially in Ms 5:37Microsoft cql server so it is a way of 5:43having multiple 5:45statements that you want to execute in a 5:48row it can get as complex so multiple 5:51operations that you want to do it even 5:53has the capability to be able to pass in 5:55certain variables and information that 5:57you want to serialize or hyd this 6:00particular uh role of of of um way they 6:03should execute um you'll find other 6:06things of doing 6:09transactions and these are very good 6:12because they're able to process a series 6:15of actual queries and if something goes 6:17wrong I want you to roll them back all 6:20right uh to do all the data there so um 6:24and then lastly what I love to mention 6:26is I do want you to after you kind of 6:29conquer a bit of these um and these are 6:31all dependent upon the actual databases 6:33that you're using I had my start um in 6:37in MySQL and 6:40postgress um and then I started to work 6:43with a lot of Enterprise databases where 6:44you had more of these particular 6:46interise features that you could kind of 6:48do and you pick your database depending 6:50on the project that you want to do but 6:52in today's world you're going to kind of 6:54see this particular acronym A 6:57Lot which is object relational mapping 7:00so arm and there'll be a series of 7:02Frameworks out there now you're going to 7:04be confronted with that early in your 7:06education on SQL but I highly recommend 7:09that you go through the basics first 7:12because what this is going to do is be 7:14able to say you have you map the context 7:17of your application whatever kind of 7:19object that you're working with so say I 7:21was doing that building that bookstore 7:23database with books and authors so I can 7:26just say books create many or create one 7:30all right and depending on which 7:32database I use it will actually the arm 7:35software framework will map to the 7:37syntax required for that particular 7:40destination database and so it makes it 7:42very very portable for me to go and 7:45really offis skates away the ability of 7:48writing queries but I do uh highly 7:51recommend that you get into the practice 7:53of writing queries first work your way 7:55up work with different 7:57databases um and then depending on your 8:00project needs the you know arm layers do 8:03actually make the process of getting 8:05started with a project very very fast 8:08because you don't have to spend time 8:09writing all those uh but that's kind of 8:12the way I definitely want you to learn 8:14it's the way that I learned this and 8:16become the expert that I am uh today so 8:21uh in conclusion this is SQL I want you 8:24to definitely read uh put in the 8:26comments below your favorite database 8:28that you like to work with and some of 8:30your adventures around SQL I want to see 8:32hear about some of those crazy queries 8:34that you've written uh 8:36before until next time technically yours 8:39Senor espa if you like this video and 8:42want to see more like it please like And 8:45subscribe if you have any questions or 8:47want to share your thoughts about this 8:49topic please leave a comment below