mardi 29 mars 2016

Get the highest id from a specific where clause

I have 4 records on my guests database.

enter image description here

I'm trying to query to the guest that has note_display = 1 and have the highest id.


I've tried

$last_note = DB::table('guests')->where('note_display','=',1)->where('id', DB::raw("(select max(`id`) from guests)"))->first();

I got

Trying to get property of non-object


I'm a lil stuck now, any hints will be a huge helps ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1WVKCRb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire