From the course: MySQL Essential Training

A brief overview of SQL - MySQL Tutorial

From the course: MySQL Essential Training

A brief overview of SQL

- [Bill] Hi, I'm Bill Wyman. SQL stands for Structured Query Language, a common language for querying and manipulating data in a relational database management system. Every system has its own variation of SQL, and MySQL is no different. The basics are the same, but the details can be very different. An SQL statement begins with a keyword and ends with a semicolon. Technically, the semicolon is a statement terminator in SQL. That means that it's always required. Some systems, including MySQL, may use the semicolon as a separator in some contexts. This means that it's not always required if there's only one statement. The semicolon is always allowed, and so it never hurts to use it, and I recommend that you get in the habit of using it all the time. SQL statements are not case sensitive. This means that capital letters and lowercase letters are treated as the same. So these two statements are effectively identical. By default, most symbols in MySQL are also not case sensitive, but there are exceptions. In this example, the table name may or may not be case sensitive, so these two statements may or may not be equivalent. If your MySQL server is running on Windows or a Mac, the table name will likely not be case sensitive, and these two statements will be equivalent. If your MySQL server is running on a UNIX system or any operating system with case sensitive file names, the table name may be case sensitive, and these two statements may refer to two different tables. Keep in mind that MySQL allows configuration options that may change this behavior. It is possible to configure your server so that all symbols are case sensitive. I suggest that you always write your SQL consistently, including the case of your symbols. This will make your code as portable as possible. And remember, your server is often running on a different operating system than your desktop, so even though your desktop is Windows or Mac, your server may not be. This is an example of a standard line-oriented SQL comment. The comment is introduced by a double dash, followed by at least one space, and ends at the end of the line. Specifically, the comment is introduced by two hyphen characters with no space between them, and at least one space after the second hyphen. This is followed by the comment text, and the comment is terminated with a new line. MySQL also recognizes C-style comments, and this conforms with the latest SQL standard. This allows multi-line comments with much more ease than line-oriented comments. MySQL also recognizes single-line comments introduced with the pound character. This is not standard SQL, and I recommend that you avoid using this style of comment. You may see this in very old MySQL code, and I recommend that you change those comments to use the double dash form. A statement may have one or more clauses, depending on the syntax of the statement. For example, this select statement has a from clause and a where clause. The from clause specifies the table, and the where clause specifies a condition that must be satisfied for each of the rows selected. Functions are used to perform specific operations on data. In this example, the count function is used to find the number of rows which match the condition in the where clause. Expressions are used in SQL to derive values from data. For example, this statement has two expressions. This expression divides the population column by one million in order to display the population in millions. And this logical expression is used to select only those rows where the population column is greater than or equal to one million. The structure of SQL syntax is very simple, but the rules may be complex, depending on the statements and usages. In the rest of this course, we'll look at specific details for many usages. For a complete tutorial on SQL, please see my course, SQL Essential Training.

Contents