Skip main navigation

Working with Azure SQL Database using Query Editor

In this video, we look at using SQL and the Query Editor on Microsoft Azure to interact with our relational database.

In this video, we’ll be introduced to the use of SQL and the Query Editor within Microsoft Azure to interact with our relational database(s).

Azure SQL databases are relational and follow the common tabular format presented earlier this week.

Server vs database

The server is the individual machine (or virtual machine) that stores the database(s). It’s theoretically possible to spread one database across many servers, but this can cause performance and management issues.

Schema vs table

Schema refers to the specific organisation the database has been set up in. It tells the database management system (DBMS) the names of the tables, the headers of the columns, and which are primary and foreign keys. This can be represented visually, or in a set of formulas that describe the constraints, often written in Structured Query Language (SQL).

Common SQL commands

SQL (pronounced see-kwil or ess-kew-el) is a programming & computation language commonly used for extracting data from or adding data to a database. Some common commands seen in the video are:

  • SELECT column1, column2, column3 – designates which column(s) you wish to see from a table (or tables). An asterisk (*) can be used to designate ‘all’ columns.
  • FROM table_name; – designates which table(s) you wish to apply the SELECT query to within the database.
    • Note the semi-colon after the table’s name; it’s not always necessary but is advised to be present after each SQL query.
  • WHERE – this clause is used to filter your results from the SELECT (or other queries) by excluding results that do not fit the given criteria.
    • For numeric values, simple statements such as WHERE column1=3; will return only results that have a value of 3 in that first column.
    • For comparing text values, quotations are needed. WHERE column2='London' OR 'Cape Town'; will only return results where the content of the second column is either London or Cape Town.
  • AS – this is used to create an alias for a column or a table. This is useful for making your results easier to read and interpret.
    • SELECT column_name(s) FROM table_name AS alias_name;
    • This alias is only temporary, and will only exist for as long as you run the SQL query.
  • JOIN – is a clause used to combine records/rows from two or more tables, based on a related column between them.

SQL supports the following comparative operators:

Operator Descriptor
= Equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
<> Not equal. Note: In some versions of SQL, this operator may be written as **!=
BETWEEN Between a certain range
LIKE Search for a pattern
IN To specify multiple possible values for a column
Note: SQL keywords are NOT case sensitive; select is the same as SELECT. Popular convention dictates that the query commands are written in capital letters to make it easier to read a query, but not necessary for it to function.

Square brackets in queries

Specifically in Microsoft SQL environments, square brackets [ ] are used when keywords or special characters are in the column names or identifiers. For example, SELECT First Name FROM table1; wouldn’t work, as there’s a blank space between First and Name. The correct query would be SELECT [First Name] FROM table1;.
Note: Why not explore futher the new SQL commands introduced in this step? You can find more information at W3Schools’ SQL section.

In the next video, Graeme will explore some other means of interacting with the data in our databases.

This article is from the free online

Microsoft Future Ready: Fundamentals of Big Data

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education