SQL for everybody part I
Developers solve different problems for a variety of contexts. Some deal with the frontend and don’t ever see a database while others deal with the backend and work with databases regularly. There are even those that do a mixture of the two. Regardless of where you fall and even if you are not a developer, everybody can benefit from knowing a little SQL.
SQL 101
SQL stands for Structured Query Language and is used for querying data from databases. The syntax is simple and concise. Let’s get started with an example of a SELECT statement.
SELECT * FROM color
The statement here is selecting all (*) the records (rows) from a table called color. This is the most common statement used to pull all the data from a table.
Filtering
There are limitation to pulling all the data. In tables where there are thousands of thousands of records, sometimes its easier to do analysis by filtering out records that aren’t useful by adding a WHERE clause.
SELECT * FROM color
WHERE color.type = 'primary'
The updated statement result is now only showing colors that are ‘primary’ types.
Querying data
Using these two simple commands are a good way to get acquainted with database tables. In the next part, we’ll cover how to use more advanced techniques to help filter data.