
May 4th, 2008, 04:05 PM
|
|
Registered User
|
|
Join Date: May 2008
Posts: 1
Time spent in forums: 50 m 15 sec
Reputation Power: 0
|
|
|
Select data from 4 tables
I have te following tables
-customer
-bestelling_buffer
-bestelling_details
-producten.
i need al the data from
-customer
-bestelling_buffer
-bestelling_details
The ID of producten is also stored in bestelling_buffer (foreign key)
i would also like to show the product from whom the id is stored in bestelling_buffer
Ik have
PHP Code:
SELECT *
FROM bestelling_buffer, bestelling_details, customer
WHERE bestelling_buffer.klant_code='".$_SESSION['klant_code']."'
AND bestelling_details.klant_code='".$_SESSION['klant_code']."'
AND customer.klant_code='".$_SESSION['klant_code']."'");
I thougth this would work (but is doesnt)
PHP Code:
SELECT *
FROM bestelling_buffer, bestelling_details, customer
LEFT JOIN producten
ON bestelling_buffer.product_id =producten.id
WHERE bestelling_buffer.klant_code='".$_SESSION['klant_code']."'
AND bestelling_details.klant_code='".$_SESSION['klant_code']."'
AND customer.klant_code='".$_SESSION['klant_code']."'");
i also tried this
PHP Code:
$sel_products = mysql_query("
SELECT *
FROM bestelling_buffer
LEFT JOIN producten ON bestelling_buffer.product_id=producten.id
LEFT JOIN bestelling_details ON bestelling_buffer.klant_code=bestelling_details.kl ant_code
LEFT JOIN customer ON bestelling_details.klant_code = customer.klant_code
WHERE customer.klant_code='".$_SESSION['klant_code']."'");
As you can see i am trying a lot of wrong things. Help would be much appreciated
|