Alankar
Alankar

Reputation: 483

Inner join query is showng 0 results

I am facing strange issue with OpenCart (v: 3.0.3.7) query. I am trying to pull product and product_descrition table data using Inner Join but getting 0 result. This query is working fine if I am using Left Join instead of Inner Join. Also query is showing result for product_id but null values in pd.name.

Note: Same query is working find when I am running it directly in phpMyAdmin

SELECT p.product_id, pd.name
FROM oc_product p
Inner JOIN oc_product_description pd ON (p.product_id = pd.product_id) AND ( pd.name LIKE "%test%") AND p.manufacturer_id = "14"
GROUP BY p.product_id
ORDER BY p.product_id ASC

Upvotes: 0

Views: 53

Answers (1)

K. B.
K. B.

Reputation: 1430

Why you need INNER JOUN? use LEFT JOIN... You can try this...

SELECT DISTINCT * FROM oc_product p LEFT JOIN oc_product_description pd ON (p.product_id = pd.product_id) AND pd.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY p.product_id ORDER BY p.product_id ASC

Upvotes: 1

Related Questions