java-textbook

SQL

SQL, or Structured Query Language, gives you the power to access and manipulate databases. A database is a structured set of information stored on a computer or server.

Sets of data are stores in tables. Tables consist of rows and columns.

Example

Here’s an example of a table called Students:

Students

StudentID StudentName StudentEmail StudentPhone City
1 Orlando Orlando@aca.com 123-456-7891 Houston
2 James James@aca.com 123-456-7891 San Antonio
3 Kelly Kelly@aol.com 123-456-7891 Austin
4 Kari Kari@aol.com 123-456-7891 Austin
5 Jose Jose@aca.com 123-456-7891 Dallas

The following command selects all the data from the table called Students:

SELECT * FROM Students;

*** Important SQL Commands

To select the columns StudentName and StudentEmail from the Students table:

SELECT StudentName, StudentEmail FROM Students;

To select all the students who live in Austin from the Students table:

SELECT * FROM Students
WHERE City='Austin';

Assignment

Complete the SQL Zoo Tutorial to practice working with SQL. Please complete everything through the “SUM and COUNT” section, including the quiz for that section.

All the material about JOIN operations is optional.

More Practice