SQL’s syntax is a lot different than other web programming languages. It is extremely readable and very specific. In the most basic form, we will only be using SQL to create queries to select or change data (data manipulation). A query is just SQL code designed to do just that. So, we will not deal with creating tables, databases, or indexes and we won’t be deleting them either. I may add a part about them later, but the majority of web hosting companies offer fantastic tools that do those tasks for you. Let’s get to your first SQL query::
One of the most simple queries you will ever write. Look at how easily that can be read. SELECT some asterisk thing FROM some table_name. First, I will be using things like table_name, where that will be a real table name like users, reviews, items, etc. The * (asterisk) simply means everything in SQL. So, in this case, the asterisk means select every column in that table.
What about the capitalized words? I don’t know of exactly what to call these things because they are so arbitrary, they are keywords really. SQL is made up from these keywords and functions, and it is a relatively tiny language compared to server side languages. SELECT tells SQL that this is a statement, but FROM tells SQL where to perform the statement.
Notice how SELECT and FROM and in uppercase. While I should tell you that is how it must be written, it isn’t. SQL isn’t case sensitive in terms of keywords and functions, but please, please, please always write the actual SQL syntax in uppercase. It helps distinguish the SQL from the column names and values. If you do this one simple trick, people will think you know what you are doing. Go ahead, pretend like you do. They won’t notice.