Skip to content
Advertisement

What does the “i” stand for in this SQL query?

I’m looking at a bunch of SQL query’s made by another individual and am trying to interpret how they were made. I’m fairly new to SQL so its involved a lot of Googling, its also my first time posting a SQL question.

I’ve seen the letter “i” entered in a lot of queries. Below is an example query. Does anyone know what this “i” stands for in the “select year (i.InspectDate)” line”?

enter image description here

Thanks

Advertisement

Answer

It’s an alias, declared here:

Remember SQL is not case sensitive, so the I alias declared as a mnemonic for the Inspect table is the same i used in the SELECT list.

It’s good practice to use table/view aliases in queries, because aside from saving you a bunch of typing you sometimes need to reference more than one instance of the same table; aliases allow you to disambiguate which instance you mean. They also help with query portability.

This question demonstrates the use of single-letter or very short mnemonics for each table/view. Single-letter variables are discouraged in most programming circles, but it’s fine for this purpose, as long as it’s a mnemonic for the full name. The practice is very common and well-understood among database developers. You may, however, sometimes run into sequential single-letter aliases (a, b, c, continuing in the order the tables/views appear), and that is not good practice.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement