WK4 SQL Queries: Basic queries Flashcards
SELECT
SELECT indicates which columns to return.
FROM
FROM indicates which table to query.
We’re going to determine which computer has been assigned to a certain employee. Let’s say we have access to the employees table. The employees table has five columns. Two of them, employee_id and device_id, contain the information that we need. We’ll write a query to this table that returns only those two columns from the table.
select employee_id, device_id
from employees;
Suppose you wanted to know what department the employee using the computer is from, or their username, or the office they work in. To do that, we can use SQL to make another statement that prints out all of the columns from the table. We can do this by placing an asterisk after SELECT. This is commonly referred to as select all. Now, let’s run this query to the employees table in SQL. And now we have the full table in the output.
Syntax
Syntax refers to the rules that determine what is correctly structured in a computing language. In SQL, keywords are not case-sensitive