A lot of people say "S..Q..L", by separating the letters or some pronounce it as "sequel". It's up to you, I like "sequel", it just sounds cooler. SQL is a superrrrrrrrrrr important skill to learn when dealing with huge amounts of data sets. SQL, which stands for Structured Query Language, is a programming language used for retrieving data and manipulating the data models (aka in table format). To specify that, it is used to extract data from a relational database. A relational database is basically a bunch of tables put together. This skill is very useful for applications in machine learning, when you are dealing with a vast amount of data sets and you need a way to extract the important information so you can predict things with future data. In a table, the rows are the records of the database, and the columns are the fields or parameters of the data. So for example, if we were dealing with a table of movies, then the fields of a movie can be 'genre', 'rating' and 'duration'. Every row, or record, would consist of a single movie. The 'SELECT' and 'FROM' commandsJust like any other programming language, SQL comes with certain syntax. The syntax is used to gather specific information from a huge table, so you can process the most important and valuable information you need. The SELECT and FROM commands are one of the foundational commands of SQL, used to extract the columns of a table. The commands in SQL can be in uppercase or lowercase, but most people prefer uppercase since its easier to distinguish from the column and table names. For instance, if we had a table featuring regular customers in a store, and we want to extract the name column of the customers table, we would write: SQL Tutorial 1
Suppose our customer database kinda looks like the one above. The above commands are basically focusing on the 'name' column in the table, highlighted in orange. What if you also wanted to take in the age aspect of the customers into consideration? If you want to select more than one column of a table, you simply have to add a comma to the SELECT statement and type in the additional column right next to it. Also, at the end of every SQL statement, we have to add a semicolon for the compiler to understand that the SQL commands are over. If you want to select all of the columns of the table (so you are essentially selecting the whole table), you need to type in the asterisk symbol next to SELECT like this: ' WHERE', 'LIKE' and 'AND' commandswhat if you want to make your commands even more specific and extract those details from large datasets? What if you want to get the names of the customers that start with the letter A? Or what if you wanted to get the customers who are 18-25 years old? To filter a dataset, you can use the WHERE command. The 'WHERE' command allows you to filter the data in order to get the information you need. So, if you want to get the names of the customers who are in 18-25 age range, you first select all of the column 'name' from the customers table. Then, you use WHERE to get the names of the customers who are 18 years old or older. But we have a boundary. We need to get the customers who are younger than 25 AND older than 18. This is where the AND command comes in. The AND command allows you to combine conditions of a particular field. So since we need to find customers who are older than 18 but younger than 25, we can use the AND command to restrict the range of the age. To get the customers who are 18-25 years old
That's a wrap for SQL! These are like the simple, intro commands; there are lots more!!!!!!!!!!!!!!!!!
0 Comments
|
Archives
December 2020
Topics
All
|