Skip to main content

Structured Query Language (SQL)

Structured Query Language (SQL) is the query language for relational databases. To create a SQL query the user must specify what data to return, what tables to look in, what relations to follow (how to connect tables together, called JOINs), and—optionally—how to order the data that meets all of these set conditions.


  • The following query tells the database that you want two columns (displayName and title), with one of those columns consisting of data from the artist table (containing information about artists) and the other consisting of data from the object table (containing information about art objects). To get data from both tables, you need to join them on a common field (artistID) that appears on both tables. You can imagine that an artist will have a unique artistID and that artistID will also appear on the same row on the object table for each art object that is known to have been made by that artist. While it is a unique field for the artist table, it is not for the object table, since you can have multiple objects in the database by the same artist. This query tells the database to return all rows where (1) there is a match between these columns, (2) where the artist.displayName field has the word “Rembrandt” somewhere in it, and (3) where the object.dateMade field contains a date after 1 January 1660. Finally, this query tells the database to return all of these rows to us in order of the objectID.
  SELECT artist.displayName, object.title
FROM artist
JOIN object ON artist.artistID = object.artistID
WHERE artist.displayName LIKE%Rembrandt%AND object.dateMade >1/01/1660
ORDER BY object.objectID

Further Resources