Jump to content

Prestashop 1.6.1.14 - Database Query Returns 2 Results


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)
Link to comment
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...