|
Join tables
Introduction JT
So far we have been considering the problems with one table. Let’s study our
problem in the situation when we have more tables to be joined, discussing, as
well how to utilize Vdf objects.
For problem treating, we shall look at tables having the
following fields:
Table name : "order"
|
order_id
customer_id
number_invoice
order_date
value_invoice
payment
way_payment |
C (6)
C (6)
C (6)
D (8)
N (10,2)
L (1)
C (15) |
primary key
candidate key |
Table name : "customer"
|
customer_id
company_name
phone
address
city
|
C (6)
C (40)
C (24)
C (60)
C (15) |
primary key
|
While
writing SQL commands, we shall not take into consideration any special
conditions for the formation of “Select” expressions; we believe the user to be
having sufficient knowledge of SQL
‘Where’ condition parts
The user wants to extract
all the facts and he will write the following SQL expression:
SELECT ;
order. number_invoice ;
order. order_date ;
order.value_invoice ;
order. payment ;
customer. company_ name ;
FROM order, customer ;
WHERE ;
order.customer_id = customer.customer_id
cxWhereCond = “order.customer_id =
customer.customer_id” is the result of joining two tables into one query.
We should proceed. If the user
wants to extract all the fact with the fact dates bigger than 23/05/1995, he
will write the following SQL expression:
SELECT ;
order. number_invoice ;
order. order_date ;
order.value_invoice ;
order. payment ;
customer. company_ name ;
FROM order, customer ;
WHERE ;
order.customer_id = customer.customer_id .AND. ;
order_date >= 23/05/1995
cxWhereCond = “order.customer_id =
customer.customer_id “ + “.AND. ”
+ ;
“order_date >= 23/05/1995”
|