PHP beginner |
|
Query Joins
<?php
$query = "
SELECT
flowers.id AS fid
flowers.artikelnrg AS ag,
flowers.artikelnrk as ak,
flowers.qty1,
flowers.qty2,
flowers.price1,
flowers.price2,
flowers.special,
flowers.price12,
flowers.price22,
payments.id AS pid,
payments.quantitysmall,
payments.quantitybig,
payments.date,
paymentsnote.note,
paymentsnote.datum
FROM
payments
LEFT JOIN
flowers
ON
(flowers.id = payments.flower_id)
LEFT JOIN
paymentsnote
ON
(paymentsnote.customer_id = ".$id."),
(paymentsnote.datum = payments.date)
WHERE
done = 0
AND
date = NOW()
AND
customer_id = ".$id);
?>
<?php $query = " SELECT flowers.id AS fid flowers.artikelnrg AS ag, flowers.artikelnrk as ak, flowers.qty1, flowers.qty2, flowers.price1, flowers.price2, flowers.special, flowers.price12, flowers.price22, payments.id AS pid, payments.quantitysmall, payments.quantitybig, payments.date, paymentsnote.note, paymentsnote.datum FROM payments LEFT JOIN flowers ON (flowers.id = payments.flower_id) LEFT JOIN paymentsnote ON (paymentsnote.customer_id = ".$id."), (paymentsnote.datum = payments.date) WHERE done = 0 AND date = NOW() AND customer_id = ".$id); ?>
Ik heb bovenstaande query. Maar hij werkt niet (en ik weet niet waarom niet).
Er komt dus een klant_id binnen. En ik wil de selectgegevens uit de volgend tabellen halen:
Payments:
- id, customer_id, flower_id, quantitybig, quantitysmall, date, done
Flowers:
- id, (....)
Paymentsnote
- id, note, customer_id, done, datum
Ik wil dus dat de datums gelijk moeten zijn én het id nummer van de customer.
Zou iemand me met deze query kunnen helpen:$ alvast super bedankt!
|