Notas
SQL- Relational Databases
Conteúdo das notas (1)
Página 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
Informações
- Descrição
- GCSE Computer Science (Databases) Notas sobre SQL- Relational Databases, criado por Caitlin Bergan-Gander em 22-02-2016.
- Criado por
- Caitlin Bergan-Gander
- Visualizações
- 2
- Avaliação