I need to add an additional join to a query but I'm not sure what to join it on.
SELECT DISTINCT * FROM {$this->prefix}category c
LEFT JOIN {$this->prefix}category_description cd
ON (c.category_id = cd.category_id)
LEFT JOIN {$this->prefix}category_to_store c2s
ON (c.category_id = c2s.category_id)
WHERE c.category_id = '" . (int)$category_id . "'
AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "'
AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "'
AND c.status = '1'
I need to now join my url_alias table via a column value like:
SELECT keyword FROM {$this->prefix}url_alias
WHERE query = 'category_id=" . (int)$category_id . "'
-- EDITED TO CLARIFY --
This is for an OpenCart project that needs to simplify the url rewriting by adding the keyword to the existing category/product/manufacturer queries.
How about this:
SELECT DISTINCT * FROM {$this->prefix}category c
LEFT JOIN {$this->prefix}category_description cd
ON (c.category_id = cd.category_id)
LEFT JOIN {$this->prefix}category_to_store c2s
ON (c.category_id = c2s.category_id)
LEFT JOIN {$this->prefix}url_alias u
ON u.query = CONCAT('category_id=', c.category_id)
WHERE c.category_id = '" . (int)$category_id . "'
AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "'
AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "'
AND c.status = '1'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.