Tabele PHP

Previzualizare laborator:

Extras din laborator:

Joins and Keys

Sometimes we have to select data from two or more tables to make our result complete. We have to perform a join.

Tables in a database can be related to each other with keys. A primary key is a column with a unique value for each row. The purpose is to bind data together, across tables, without repeating all of the data in every table.

In the "Employees" table below, the "Employee_ID" column is the primary key, meaning that no two rows can have the same Employee_ID. The Employee_ID distinguishes two persons even if they have the same name.

When you look at the example tables below, notice that:

- The "Employee_ID" column is the primary key of the "Employees" table

- The "Prod_ID" column is the primary key of the "Orders" table

- The "Employee_ID" column in the "Orders" table is used to refer to the persons in the "Employees" table without using their names

________________________________________

Employees:

Employee_ID Name

01 Hansen, Ola

02 Svendson, Tove

03 Svendson, Stephen

04 Pettersen, Kari

Orders:

Prod_ID Product Employee_ID

234 Printer 01

657 Table 03

865 Chair 03

________________________________________

Referring to Two Tables

We can select data from two tables by referring to two tables, like this:

Example

Who has ordered a product, and what did they order?

SELECT Employees.Name, Orders.Product

FROM Employees, Orders

WHERE Employees.Employee_ID=Orders.Employee_ID

Download gratuit

Documentul este oferit gratuit,
trebuie doar să te autentifici in contul tău.

Alte informații:
Tipuri fișiere:
doc
Diacritice:
Nu
Nota:
8/10 (3 voturi)
Nr fișiere:
1 fisier
Pagini (total):
10 pagini
Imagini extrase:
10 imagini
Nr cuvinte:
1 783 cuvinte
Nr caractere:
11 109 caractere
Marime:
19.09 KB (arhivat)
Nivel studiu:
Facultate
Tip document:
Laborator
Domeniu:
Engleza
Tag-uri:
select, distinct, order
Data publicare:
10.07.2014
Structură de fișiere:
  • Tabele PHP.doc
Predat:
la facultate

Ai gasit ceva în neregulă cu acest document?

Te-ar putea interesa și:
PHP (PHP: Hypertext Prepocessor), cunoscut in versiunile mai vechi si sub numele de PHP/FI...
I. NOTA INTRODUCTIVA Disciplina PROGRAMARE WEB AVANSATA asigura pregatirea studentilor pentru...
Acest proiect consta in realizarea unei aplicati WEB, prin intermediul careia se doreste emularea...
In ultimele doua decenii dezvoltarea fara precedent a tehnologiilor informationale determinate de...
Introducere In aceasta aplicatie a trebuit sa legam bazele de date MySql cu limbajul de...
Sus!