Jump to content

Prestashop 1.6.1.14 - Database Query Returns 2 Results


Go to solution Solved by bellini13,

Recommended Posts

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 by Enthu86 (see edit history)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More