Table of Contents

Web Development Lesson 7 - Databases

Tables

Objective

In this activity you will use a new tool to get a good look at the structure of a database.

Setup

There is nothing to set up in this exercise.

Tool: PHPMyAdmin

Tables

Fields

SELECT Queries

SELECT * FROM `heroes` 

Conditions

SELECT * FROM `heroes` WHERE 1
SELECT * FROM `heroes` WHERE power='Magic'
SELECT * FROM `heroes` WHERE power='Magic' AND hero_villain='Hero'
SELECT * FROM `heroes` WHERE power='Magic' OR power='Technology'

Sorting

SELECT * FROM `heroes` WHERE power='Magic' OR power='Technology' ORDER BY first_appeared
SELECT * FROM `heroes` WHERE power='Magic' OR power='Technology' ORDER BY first_appeared DESC

Limit Results

SELECT * FROM `heroes` WHERE power='Magic' OR power='Technology' ORDER BY first_appeared DESC LIMIT 1

Next: Joins