Reputation: 267
Maybe anyone can help me?
This is my controller.
$takegolongan = Pekerjaan::select ('LEFT('golongan_jabatan', 1)')->where('cno', '00001222')->get();
echo $takegolongan;
This is the data that I want to take :
output on the screen (error):
Upvotes: 1
Views: 2052
Reputation: 404
You should add single quote inside the double quote or you should use backslash, I can only see the issue of quotes. Like:
$takegolongan = Pekerjaan::select ("LEFT('golongan_jabatan', 1)")->where('cno', '00001222')->get();
Upvotes: 1
Reputation: 121
You can use DB::raw() like this:
use DB;
$takegolongan = Pekerjaan::select(DB::raw('LEFT(`golongan_jabatan`, 1)'))
->where('cno', '00001222')
->get();
Upvotes: 1