Warning 29.3.1.
The first time you run a database problem, it will take a little while for the database file to load. Be patient. Once it is loaded by your browser, future runs using the same database should be much faster.
SELECT
is:SELECT columns FROM table;
SELECT
are generally written using all upper case, while column names and table names use lower case. This is a convention to make statements easier for people to read - it is also valid to use lowercase for the keywords.--Still all one statement:
SELECT
columns
FROM
table;
;
symbol. A final difference is how we make a comment. In Python, we use #
to make a comment in the code. In SQL, we use --
to tell the computer to ignore the rest of the line.SELECT
to get all the data from the trip_data
table. The following SQL query is an example of how to do so. It asks the database to SELECT
all columns (*
is a shorthand that means “all columns”) FROM
the table named trip_data
.SELECT
, it might not make sense to ask for all of the columns in a table. If we want to answer a question about the length of rides, we probably do not need the information about station numbers or bike numbers. To simplify the data we get, and reduce the amount of information that must be sent from the database to our program, we would want to specify a list of columns we care about instead of using *
. To select just the start_date
, end_date
, and duration
columns, the query would look like the following:start_date, end_date, duration
.*
and look at the returned data to find the column names you care about.