In previous posts, I have written about different ways of using SQL, from entering, updating and deleting data to making queries using different filters. In this post, I will write about another type of filter for queries called the LIKE operator.
The LIKE operator is specifically used with the WHEN clause. This operator is used when one is looking for a specific pattern within a column. For an example, we are working in a clients table. This is the table where any personal information like name, birthdate, address and phone number might be found. We might be searching the table…
Over the course of the past few posts, I have been writing about how to create, delete, and query in SQL. For this post, we will take a closer look into a section about queries. We will be specifically going over the
WHERE clause is a statement that filters a table based on certain conditions. The query then will only return the columns and observations that meet the conditions given within the
WHERE clause. The basic formula for using the
WHERE clause is the following:
SELECT <column_1>,..., <column_n>
A basic example…
In the past series of posts, I have written about how to enter, delete, and write basic queries for information from a data table. However, all the information you may need for a project is unlikely to be found in a single data table. This is especially true for SQL as it is known for its connection to relational databases. To gather all this information from a variety of tables, we must join different data tables.
In a previous post, I have written about joins and using them in python. For more information on joins, you can read that post…
In past posts, I have written about databases and data tables, entering data, data types, and using different types of functions in query statements. In this post, I will go over using CASE statements in a SQL query.
So far, we have used string and aggregate functions in queries, but what if you need a new column based on information from another column, where there are a select group of results depending on that information? If one already knows other programming languages, you have most likely seen something similar in an if else or elif statement. …
In a previous post, I went over some of the string and numeral data types that may be used when creating data tables. One of the types that I did not include is date and time data types. The reason for this is because a lot of people when they are first learning about date and time data types have a lot of difficulty and struggle with it. So I wanted to take the time to write specifically about this subject.
There are three commonly used types for date and time. Those are the DATE, DATETIME and TIMESTAMP. As you…
In previous posts, we have gone over creating databases and tables, how to add, update, and delete data from those tables, and a number of string functions that can be used in select queries. After going over ways of using strings to understand the data, we will look more deeply into aggregate functions to gain a better understanding through the integer columns.
There are a good number of aggregate functions, and we will go over some of the most commonly used ones. There are functions such as
MAX() , and
COUNT() . …
So in my past few posts, I have written about databases, creating tables, entering and updating data in those tables. In my introduction to SQL, I wrote a few examples of queries in the language. In this post, I will dig a little deeper into queries, specifically using string functions.
There are many string functions that one can use in SQL, however there are a few that are used more often than others. We will go over a few of the most common string functions one might need to use with examples.
There are times when you will want to…
So in previous posts, I have written about creating databases and data tables. Then I wrote about inserting data into those data tables. However, sometimes we need to update information or delete a specific observation. The updating and deleting of observations in a data table will be gone over in this post.
I’m sure many of us can think of multiple possibilities where we would need to update or delete a data observation. For example, there might be a database with information about subscribers or those who have paid for a service. In this data table, there might columns indicating…
So in the previous post, I wrote about creating tables. The next step would be to think about how the data is entered into these tables. This is what we will be going over in this post.
The process to enter data is quite logical. The code to do this or ‘formula’ is
INSERT INTO <table_name>(column_name(s)) VALUES (data) . Let us break down this code or ‘formula’ into its different parts.
INSERT INTO: this makes sense due to the fact we want to enter data into the table.
<table_name>: this is self explanatory. This determines the table that…
In a previous post, I went through some of the history and the basics of SQL. In this post, we will learn about creating tables. As a quick reminder, SQL is used in relational databases. A relational database stores data in a table or multiple tables that are connected to each other in some way. So it is important to know how these tables are created in the first place.
As mentioned in the previous post, there are a number of different ‘dialects’ of SQL and there can be small differences in syntax. …