PrestashopEnthu Posted November 30, 2017 Share Posted November 30, 2017 (edited) I am writing a query with query builder. While the result is correct, unfortunately, it returns double result due to the query below. I have an "orders" table that I joined with "carrier" table by id_carrier. and also joined "orders" with "order_state_lang" with current_state and id_order_state. Query: $query = new DbQuery(); $query->select('o.id_order') ->from('orders','o') ->leftJoin('carrier','c','o.id_carrier=c.id_carrier') ->leftJoin('order_state_lang','s','o.current_state=s.id_order_state') ->where('c.name = ' . "'XXX'") ->where('s.name = ' . "'YYY'"); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); $this->context->smarty->assign( 'result', $result); Can anyone point out the mistake I did? Any help is greatly appreciated. Edited November 30, 2017 by Enthu86 (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted November 30, 2017 Share Posted November 30, 2017 How many languages do you have in your store? I suspect you have 2, so you would have to include in your query, which language you are trying to use Link to comment Share on other sites More sharing options...
PrestashopEnthu Posted November 30, 2017 Author Share Posted November 30, 2017 Hi bellini13, Thank you so much for the clarification. After checking, indeed, there were 2 active languages which returns 2 results. I have removed the unnecessary duplications and all is working well now. Thank you for the prompt assistance. Much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now