Noted recently at the SQLizer blog, the SQL language was first created 43 years ago. And what is remarkable about that is that SQL is still used today. According to the Stack Overflow 2017 developer survey it is the #2 programming language. Not many languages remain in use for such a long period of time. Although we’re happy to also note that Xojo celebrated our 20th anniversary in 2016!
One reason that SQL might rank so high is that it is not really a single language. Although the term SQL is used to refer to the default language used with every relational database, each version is different. SQL actually means Structured Query Language, not Standard Query Language as I often hear people refer to it. Every database that uses SQL also uses its own variant of SQL and these variants differ by just enough to be annoying, although the core commands are mostly the same. It reminds me of how BASIC was in the 1970s and 80s with different versions for each computer with nothing but the most basic (pun intended) compatibility between them.
Even though SQL is a programming language, it is not like languages you are likely most familiar with. You use SQL to write database queries that return sets of data so it works differently than just about any other language you might be familiar with (although some versions add some procedural commands).
For example if you wanted to process a bunch of rows in a typical language you might write code like this to loop through all the data:
For Each i As Integer = 0 To row.Ubound row(i) = row(i) * 2 Next
In SQL that data would be in a table and you would change the values of all the rows by using an UPDATE command:
UPDATE data SET value = value * 2;
Both effectively do a loop, but they don’t look all that similar.
Another interesting thing about SQL is that it really is a companion to any programming language you use to make apps. Since no one would ever make an actual app using just SQL, but most apps need a database of some kind, SQL becomes the 2nd language that you have to know alongside your primary language.
Xojo works with SQL by using one of its database classes to send SQL directly to the database you are using. For example, to work with a SQLite database you would use the SQLiteDatabase class for desktop, web or console app or the iOSSQLiteDatabase class for iOS apps. Those classes each have two methods to send SQL commands to the database: SQLSelect and SQLExecute. Essentially SQLSelect is used for SQL commands that return sets of data and SQLExecute is used for commands that do an action (such as create a table).
Like other programming languages, Xojo does not care what database you use nor does it care what SQL you are sending to it.
You can learn about some common SQL commands in the Database Operations topic of the User Guide at the Xojo Dev Center.