Repeat Signage V4 help

Structured Query Language (SQL) 

Help home


SQL

SQL is a programming language which allows you to write queries to retrieve information from databases.  Different databases, such as Microsoft Access and MySQL have slightly different versions and the syntax can differ slightly.  Let's say you have a database and you have a table in your database called 'Countries', which looks like:


ID Country Currency Capital
       
1 United States US Dollar Washington, DC
2 United Kingdom Pound Sterling London
3 Australia Australian Dollar Canberra

If we wanted to collect all of this information, to put in a data grid for example, then we could write an SQL statement like:

SELECT * FROM Countries

and all the information would be collected.  However, we might not want all of the colums, so we could just narrow it down the the ones we wanted with:

SELECT Capital, Country FROM Countries

which would just bring us back:

ID Country Currency
     
1 United States US Dollar
2 United Kingdom Pound Sterling
3 Australia Australian Dollar

If we look at the above information, then the countries are not in alpabetical order, so we could order them by using the ORDER BY command:

SELECT Capital, Country FROM Countries ORDER BY Country

which would return:

ID Country Currency
     
3 Australia Australian Dollar
2 United Kingdom Pound Sterling
1 United States US Dollar

We could further filter this if we just wanted a specific country using a WHERE command:

SELECT Capital, Country FROM Countries WHERE Country = 'Australia' ORDER BY Country

which would return:

ID Country Currency
     
3 Australia Australian Dollar


The above just gives a quick idea on how information can be collected.  Databases such as Microsoft SQL Server and MySQL can be hosted on servers on the Internet or on a network and users can connect to these database to collect information.  This is why filtering the columns down to just the ones we want and filtering the records down to just the ones we want is very important as it then means that only the required information is sent over the Internet, which is faster and requires less work for the database server.

See the Wikipedia entry on Structured Query Language for more information.