Structured Query Language is a programming language specially designed for managing relational databases. All the popular relational database management systems use it to operate their databases. SQL has been around since the 1970s; positively ancient by web standards.
A typical SQL query is below:
SELECT * FROM users WHERE ID=2
This query would select all information in a row from a table called ‘users’ in the database corresponding with the user with an id
of 2.
SQL commands can be written and executed manually in applications or command lines, but are usually written into a scripting language and programmatically executed. For example, in the case of the WordPress content management system, an SQL command retrieving info from the database would be made with PHP. Here’s an example of an SQL command embedded in PHP:
<?php $result = mysqli_query( 'localhost', 'Select * FROM users WHERE ID=2' ); ?>
The SQL command is encapsulated in the PHP command. The row with information about the user will be held in a PHP variable called $result
, which can be interpreted and manipulated as necessary.
Read more about SQL at the Wikipedia SQL article.