Back to articles list September 27, 2018 - 5 minutes read How to Begin Running SQL Queries Ignacio L. Bisso Ignacio is a database consultant from Buenos Aires, Argentina. He’s worked for 15 years as a database consultant for IT companies like Informix and IBM. These days, he teaches databases at Sarmiento University and works as a PostgreSQL independent SQL consultant. A proud father of four kids with 54 years in his backpack, Ignacio plays soccer every Saturday afternoon, enjoying every match as if it’s his last one. Tags: get started how to in sql installation guide learn sql SQL basics In this article, I’ll explain how to run a SQL query to help you execute your first one. Let’s jump right in! Running SQL queries for the first time is not a complex task, but it can seem intimidating at first if you’re a complete beginner. But once you get past that initial roadblock, you’ll be able to focus on learning SQL and writing more interesting queries to meet your business needs. Running SQL Queries: The Ingredients You’ll need these three things for running SQL queries: A database engine An SQL client An SQL query What is a Database Engine? A database engine is like a data repository; it contains all the data (tables, procedures, and more) related to your organization, business, or personal databases. Installing a database engine is fairly easy, and it’s the first step you should take to be able to run SQL queries on your computer. There are many different database engines on the market, such as Oracle, SQL Server, DB2, MySQL, and PostgreSQL. Some of these engines are developed by companies for commercial or limited personal use. For example, Microsoft developed SQL Server, while Oracle developed the Oracle and MySQL engines. Among the engines on this list, PostgreSQL is a special case because it is an open-source database engine. That means it’s developed by a community of developers, and anyone can use it for free (including you!). It’s important to understand that all database engines speak the core SQL language. So if you learn SQL while working in Oracle, you can easily change gears and work with SQL Server, PostgreSQL, or any other database engine that uses standard SQL or a derivative of it. Getting Started with SQL Queries: Choosing a Database Engine To start, you need to identify what database engine you’d like to use. You’ll also need some additional technical information, like the names of the tables where the data you want to work with will be stored. In SQL, data is organized and grouped in tables. A database engine consists of several databases, which in turn consists of tables that store data and procedures that manipulate data. As an example, consider the following two independent database engines, one for a company named GoGreen that runs in Oracle and another for a sports retail company named BeOlympic that uses PostgreSQL. Small companies tend to use free database engines like PostgreSQL or MySQL, while medium-sized companies and corporations tend to use more robust database engines like Oracle, DB2, or SQL Server. However, it’s important to note that these days, almost all database companies offer free versions of their databases, perhaps with some limitations, oriented towards small businesses. The SQL Client: Your Connection to the Database Engine This step can take some time, but it’s not too difficult, and once you install an SQL client, you won’t need to do so again (unless you decide to work with another database engine). Once you’ve downloaded your selected database engine, you’ll need to download an SQL client to be able to communicate with that engine. Fortunately, in some cases the SQL clients come pre-installed with database engine installations, in other cases you need to download, install and configure it. For example, on Windows the pgAdmin client is part of the PostgreSQL database engine installation; it’s an interactive interface that allows you to create your own databases, add tables, write queries, and do all kinds of neat things. Take a look at the “How to Install PostgreSQL on Windows in 5 Minutes” article to understand installation and configuration of Postgres engine and pgAdmin SQL client. SELECT product_id, description, cost, price FROM products Here are the results of the query: Writing an SQL Query: the Final Piece of the Puzzle At last, we’ve arrived at the promised land. Having installed a database engine and an appropriate SQL client, you’re now ready to learn how to run a SQL query. This is the simplest query you could write: SELECT * FROM products For the sports retailer database, we’d write: SELECT * FROM clients. Once you nail down the basics, you’ll learn how to write and run a SQL query of a higher level by adding new clauses, like the WHERE clause to filter records. Another important aspect of the SQL language is PL-SQL (PL stands for Programing Language), which is a language for writing procedures or functions that you can later execute on the data in your database. These procedures use variables, conditional statements, control statements, and lots of other programming concepts. Consider the example below. This SQL query obtains all products with a price range of 10.00 to 20.00 dollars, inclusive. Learn More about Running SQL Queries Having read this article, you know how to run a SQL query. You need to: Choose a database engine for your needs and install it. Start up the database engine, and connect to it using your SQL client. Write SQL queries in the client (and even save them to your computer). Run the SQL query on your data. SQL is a powerful language with plenty of possibilities. Even though I have years of experience working with SQL, I discover something new every week. Learning SQL is a lifelong process—start learning the basics today to begin your journey! Tags: get started how to in sql installation guide learn sql SQL basics You may also like Why Take the “SQL Basics” Course at LearnSQL.com Do you work with data? Do you want to learn the foundations of SQL? Discover why you should take our interactive online course “SQL Basics”! Read more SQL INSERT, SQL UPDATE, SQL DELETE – Oh My! Need to understand SQL INSERT, UPDATE, or DELETE? We'll get you up to speed with a comprehensive How-To and useful examples! Read more SQL Order of Operations Is the order in which SQL operations are executed important? Improve your SQL skills by learning the order of operations execution in SQL. Read more The Most Important SQL Queries for Beginners This guide discusses the 30 most important SQL queries for beginners. Let's take a look. Read more SQL Filtering 101 Sometimes, SQL queries return lots of data you don't need. Look at a simple example of filtering SQL queries to reduce the complexity of your data. Read more Essential SQL Terms to Know for Beginners and Pros In this article, we’ll explore some basic SQL database terminology you need to know to succeed in the data analysis world. Read more How to Start Thinking in SQL If you want to know how to write better SQL queries, change the way you think. Instead of using the language, start thinking in SQL. Read more SQL Hacks To Control Family Budget On Black Friday Weekend Black Friday is just getting started but not everyone has already developed money management skills. Here’s how SQL could help you control family finances. Read more How to Sort Records with the ORDER BY Clause We'll take a closer look at the ORDER BY clause in SQL – how to write it, how it works, and what it does to a relational database. Read more Oracle Top-N Queries for Absolute Beginners Top-N queries retrieve a defined number of rows from a result set, i.e. 10 best-selling cars, 5 most popular routers, 20 worst-performing stores, etc. Read more The Complete Beginner’s Guide to SQL Fundamentals Find out what SQL and databases are, and how they work together. In this article, you'll find a complete guide to SQL fundamentals. Read more Refine Results with SQL Set Operators The function of SQL set operators is pretty simple; they allow us to combine results from different SQL queries into one result set. Read more Practical Ways to Improve the Performance of SQL Queries Knowing how to improve SQL query performance is an important skill, especially when working with with large databases. In this article, you'll learn how to write more efficient SQL queries to get results faster. Read more How to Install PostgreSQL on Windows 10 in 5 Minutes It may look like a complicated task to install database software on your PC. In this article, I’ll show you how to install PostgreSQL on Windows 10 easily. Read more How SQL supports data-driven organization Businesses face many decisions. Most of them are driven by intuition, but organizations that make the most business impact use data-driven decision-making. Read more Microsoft SQL Server 2017 Installation Step by Step I’ll show you all the SQL Server 2017 installation steps to help you install it on the Windows operating system together with SQL Management Studio. Read more How to Use a SQL Wildcard SQL wildcard allows us to filter data matching certain patterns. In this article, we’ll look at everything you need to know about basic SQL wildcards. Read more Our Picks for 2020’s 7 Best Online SQL Schools Looking for the best online SQL courses but aren’t sure where to start? I evaluated the top 7 ranked online SQL schools to help you find your match. Read more Subscribe to our newsletter Join our weekly newsletter to be notified about the latest posts.