How to Write Select Statements Updated on October 26, 2021 by Christopher Maiorana 2 Minutes, 2 Seconds to Read The Select statement is a very simple but important part of SQL. At this point, if you read the What is SQL? article, I presume you have a bunch of test data to work with. The important thing about data is not always the data itself but what insights you can draw from the data. The Select statement will help you comb through that data so you find what you’re looking for. If you’re looking for a dedicated database solution, find out about getting yourself a dedicated managed server with build-in SQL suppot. You may recall, in the What is SQL? article, we mentioned creating, reading, writing, and deleting as fundamental SQL actions. Using Select statements will allow you to accomplish the “reading” action, so you can display your data in different ways, such as: A list blog postsA group of customersA bunch of cities No matter what kind of data you’ve collected, Select statements will help you sort it and read it. Selecting *All* Newsletter Respondents Imagine you had a signup form on your website. Visitors provide their name and email. And the form itself grabs their IP address. Your database may hold this information in a table called “respondents”. Each respondent will have a unique identification number. So that amounts to five columns in your table: idfirst namelast nameemailIP address For our first example, let’s say you just want to see all respondents. We can select all respondents using an * in our statement: SELECT * FROM respondents; “Respondents” being the name of our table. Make note of the syntax here. The SQL statement parts are capitalized, but this is not required. And a semi-color ; ends the statement. Select Less Data Often, it’s beneficial to be more selective with our Select statements. In the following example, let’s suppose you only want to see the names of our respondents. You could use the following statement: SELECT "first_name", "last_name" FROM respondents; This will produce the first and last name records for all of our respondents. Summing Up You can now see the basic syntax for Select statements in SQL. This is only an introduction. These statements can grow quickly in complexity. However, the basic syntax for selecting information from your database remains the same. As your need for more complicated records grows, your statements will get larger and more complex. Stay tuned in our SQL series, as we move on to discuss creating and deleting tables in our database. Share this Article CM Christopher Maiorana Content Writer II Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog. More Articles by Christopher Related Articles Database Optimization: Tips Using MySQL Tuner How to Check and Repair a Database in phpMyAdmin Create a blank database How to Create a MySQL Database Using CLI & cPanel How to Connect to a Database with MySQL Workbench Setting up a Remote MySQL Database Connection MySQL 1064 Error: You have an error in your SQL syntax Using MySQLi to INSERT Data into a Database How to get PostgreSQL on a VPS / Dedicated Server What is MariaDB?