Hi,
My N1ql query is not order by properly every time it brings the different order. i want to order it by using priority
SELECT MIN(depart.id) as id , MIN(depart.sector) as sector ,MIN(depart.picture) as picture , MIN(depart.priority) as priority FROM stitchit_initialization_hq depart WHERE depart.id IN (SELECT RAW pl.department_id FROM stitchit_initialization_hq emp_sch USE KEYS ‘schedule_3221190011’ UNNEST emp_sch.schedule_pricelist pl WHERE pl.service_id = ‘3221190019’) AND depart.type=‘department’ GROUP BY depart.id ORDER BY priority ASC
$sql = "SELECT MIN(depart.id) as id , MIN(depart.sector) as sector ,MIN(depart.picture) as picture , MIN(depart.priority) as priority FROM stitchit_initialization_hq depart
WHERE depart.id IN (SELECT RAW pl.department_id FROM stitchit_initialization_hq emp_sch USE KEYS 'schedule_$this->schedule_id' UNNEST emp_sch.schedule_pricelist pl WHERE pl.service_id = '$this->service_id')
AND depart.type='department' GROUP BY depart.id ORDER BY priority ASC";
$query = CouchbaseN1qlQuery::fromString($sql);
$query->consistency(CouchbaseN1qlQuery::STATEMENT_PLUS);
$result = $this->db_obj->query($query);
if ($result->rows != NULL)
{
$result = $result->rows;
return $result;
}
else
{
$result = NULL;
}