Week 4 - Ins and Outs of Core Data Tools Flashcards
SQL (Structured Query Language)
It can help you investigate huge databases, track down text (referred to as strings) and numbers, and filter for the exact kind of data you need—much faster than a spreadsheet can.
Query
a request for data or information from a database. When you query databases, you use SQL to communicate your question or request
Syntax
- unique set of guidelines followed by SQL.
- is the predetermined structure of a language that includes all required words, symbols, and punctuation, as well as their proper placement.
- e.g.
SELECT - choose the column you want to return
FROM - choose the tables where the columns you want are located
WHERE - to filter for certain information.
WHERE
WHERE field1 = ‘Chavez’
However, if you are looking for all customers with a last name that begins with the letters “Ch,” the WHERE clause would be:
WHERE field1 LIKE ‘Ch%’
You can conclude that the LIKE clause is very powerful because it allows you to tell the database to look for a certain pattern! The percent sign (%) is used as a wildcard to match one or more characters. In the example above, both Chavez and Chen would be returned. Note that in some databases an asterisk (*) is used as the wildcard instead of a percent sign (%).
ALIASES
- can also make it easier on yourself by assigning a new name or alias to the column or table names to make them easier to work with (and avoid the need for comments).
- This is done with a SQL AS clause. In the example below, the alias last_name has been assigned to field1 and the alias customers assigned to table.
- These aliases are good for the duration of the query only. An alias doesn’t change the actual name of a column or table in the database.