NOTE: using Lravel 4.1 framework
Hi My Sql query for POSTGRES DB is
$results1 = DB::table('vehicle_brands')
->where('vehicle_brands.caption','ilike', '%'.$_GET['key_word'].'%')
->join('vehicle_manufacturers','vehicle_manufacturers.id', '=', 'vehicle_brands.vehicle_manufacturer_id')
->select('vehicle_brands.*','vehicle_manufacturers.caption AS vm_caption');
$results = DB::table('vehicle_brands')
->where('vehicle_manufacturers.caption','ilike', '%'.$_GET['key_word'].'%')
->join('vehicle_manufacturers','vehicle_manufacturers.id', '=', 'vehicle_brands.vehicle_manufacturer_id')
->select('vehicle_brands.*','vehicle_manufacturers.caption AS vm_caption')
->union($results1)
->orderBy('vehicle_brands.caption','ASC')
->get();
return Response::json(array('status' => true,'data' => $results));
The error i am getting is as follows:
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "union" LINE 1: ... ilike $1 order by "vehicle_brands"."caption" asc union sele... ^ (SQL: select "vehicle_brands"., "vehicle_manufacturers"."caption" as "vm_caption" from "vehicle_brands" inner join "vehicle_manufacturers" on "vehicle_manufacturers"."id" = "vehicle_brands"."vehicle_manufacturer_id" where "vehicle_manufacturers"."caption" ilike %o% order by "vehicle_brands"."caption" asc union select "vehicle_brands"., "vehicle_manufacturers"."caption" as "vm_caption" from "vehicle_brands" inner join "vehicle_manufacturers" on "vehicle_manufacturers"."id" = "vehicle_brands"."vehicle_manufacturer_id" where "vehicle_brands"."caption" ilike %o%)
What am i doing wrong in the query?
Thankyou.