I have a query with twice the same sub-query.
Is there a way to do it only once?
The sub-query uses a value from the main-query.
Code: Select all
SELECT Bestel_id,klant.Klantnaam,
(SELECT count(*) FROM bestellijn WHERE bestellijn.Bestel_id=bestelling.Bestel_id) AS total_products
FROM bestelling,klant WHERE klant.Klant_id=bestelling.Klant_id AND (SELECT count(*) FROM bestellijn WHERE bestellijn.Bestel_id=bestelling.Bestel_id) >=3;