This topic is locked

Inner Join 3 Tables

6/10/2007 4:23:50 AM
PHPRunner General questions
R
Razkat author

I have 3 tables and i want to join information from those 3 tables for a new view.
The 3 tables are:
KLANTEN
KlantID

Bedrijfsnaam

Adres

Postcode

Woonplaats

Telefoonnummer

Faxnummer

Email

Website
PROJECTEN
Bedrijfsnaam

Contactpersoon

Projectnaam

Projectomschrijving

Projecteigenaar

Opleverdatum

Startdatum

Status

Opgeleverd op
UREN
Project

Medewerker

Datum

Omschrijving

Gewerkte uren
I want to have information from those 3 tables to make an invoice.
My customers gif me a project and i make hours on that project. Then i want to make a invoice from the information from those tables.
Can you help me please.
I have made a view with an innerjoin from KLANTEN and PROJECTEN but now i want to ad the information from UREN.
This is wath i have sofar:
select `KlantID`,

_klanten.`Bedrijfsnaam`,

`Adres`,

`Postcode`,

`Woonplaats`,

`Projectnaam`,

`Projectomschrijving`

From `_klanten`

inner join _projecten

on _klanten.`Bedrijfsnaam` =_projecten.`Bedrijfsnaam` where _projecten.`status` = "Voltooid"
Please help me.

Sergey Kornilov admin 6/10/2007

To help you I need to know how UREN table os related to one of other tables.

select `KlantID`,

_klanten.`Bedrijfsnaam`,

`Adres`,

`Postcode`,

`Woonplaats`,

`Projectnaam`,

`Projectomschrijving`

From `_klanten`

inner join _projecten

on _klanten.`Bedrijfsnaam` =_projecten.`Bedrijfsnaam`

inner join UREN on UREN.FieldName = _projecten.AnotherFieldName

where _projecten.`status` = "Voltooid"

R
Razkat author 6/11/2007

To help you I need to know how UREN table os related to one of other tables.


Sergey,
Thanks for your help.

The relation between the to tables UREN en PROJECTEN is Project and Projectnaam.
Can you gif me a hind.
Thanks.

R
Razkat author 6/12/2007

I have found the solution:
select `KlantID`,

_klanten.`Bedrijfsnaam`,

`Adres`,

`Postcode`,

`Woonplaats`,

`Projectnaam`,

`Projectomschrijving`,

`Medewerker`,

`Gewerkte uren`

From `_klanten`

inner join _projecten

on _klanten.`Bedrijfsnaam` =_projecten.`Bedrijfsnaam`

inner join _uren

on _uren.`Project`=_projecten.`Projectnaam`

where _projecten.`status` = "Voltooid"
Thanks.