Originally Posted by
DrByte
There's a lot more going on in the split_pages class than just the ORDER BY part that I mentioned. It was one example of why it does what it does.
You said you were trying to resolve a GROUP BY error. What are the details of that?
Trying to convert
Code:
$products_query_raw =
"SELECT bisns.product_id, pd.products_name, COUNT(*) AS num_subscribers, p.products_type, p.products_model,
p.products_quantity AS current_stock, cd.categories_name
FROM " . TABLE_BACK_IN_STOCK_NOTIFICATION_SUBSCRIPTIONS . " bisns
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
ON (pd.products_id = bisns.product_id
AND pd.language_id = " . $_SESSION['languages_id'] . ")
LEFT JOIN " . TABLE_PRODUCTS . " p
ON p.products_id = pd.products_id
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd
ON (p.master_categories_id = cd.categories_id
AND cd.language_id = " . $_SESSION['languages_id'] . ")
GROUP BY bisns.product_id";
to
Code:
$products_query_raw =
"SELECT DISTINCT bisns.product_id, pd.products_name, p.products_type, p.products_model,
p.products_quantity AS current_stock, cd.categories_name,
(SELECT COUNT(*) FROM " . TABLE_BACK_IN_STOCK_NOTIFICATION_SUBSCRIPTIONS . " b
WHERE b.product_id = bisns.product_id) AS num_subscribers
FROM " . TABLE_BACK_IN_STOCK_NOTIFICATION_SUBSCRIPTIONS . " bisns
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd
ON (pd.products_id = bisns.product_id
AND pd.language_id = " . $_SESSION['languages_id'] . ")
LEFT JOIN " . TABLE_PRODUCTS . " p
ON p.products_id = pd.products_id
LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd
ON (p.master_categories_id = cd.categories_id
AND cd.language_id = " . $_SESSION['languages_id'] . ")";
and receiving that error noted above. FWIW, I've run into this issue before with sub-queries but didn't need the sortability.
Bookmarks