I’m trying to fetch some data using only one query. I need to fetch one shop, which can have several modules (or possibly none), for each module I need one record in modules to exist.
My problem is getting all shop_modules enabled except just the first one? Is this possible without splitting it in two queries?
Thanks in advance
$sql = "
SELECT
s.*, sm.config, m.internal_name
FROM shops s
LEFT JOIN shop_modules sm ON sm.shop_id = s.id
INNER JOIN modules m ON m.id = sm.module_id WHERE s.domain = ?";
$shop = $app['db']->fetchAssoc($sql, array($subdomain));
I found this answer to a similiar question on another site: “A database query produces a result set, which is exactly like a flat file — it has rows and columns” – e.g. what I’m asking is not possible without splitting the query in two!