GoConqr has a new look! Let us know what you think.

Notes

SQL- Relational Databases

Caitlin Bergan-Gander Computer Science GCSE English 1 page

Content of the notes (1)

Page 1

SQL- Relational Databases

Joining the tables

• When

we use SQL to query related tables, we first need to list all tables that

we are using in the FROM section

• We

also have to include details of how the two tables are related. We do this in the WHERE section of the code

by specifying that the primary key in one table equals a foreign key in another

table

• E.g.

SELECT PetName, PetType

FROM tblPets , tblOwners

WHERE tblPets.OwnerID = tblOwners.OwnerID AND

tblOwners.Lname='Cratchett';

PetID

OwnerID

PetName

PetType

1

2

Fido

Dog

2

2

Fluffy

Cat

3

4

Gerald

Dog

4

3

Terence

Tarantula

OwnerID

FName

LName

1

Ronald

McDonald

2

Bob

Cratchett

3

John

Smith

4

Freddie

Mercury

Would give Results:

Fido Dog

Fluffy Cat

Information

Description
GCSE Computer Science (Databases) Note on SQL- Relational Databases, created by Caitlin Bergan-Gander on 22/02/2016.
Views
2
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?