mardi 11 décembre 2018

Laravel how to get data random row use Postgres SQL?

In Laravel 5 framework: How can I select a random row using Eloquent Postgres SQL?

i want get random 3 recomment product.

i find code:

$recomment_product = Product::whereRaw("name = '".$product->name."' and gender = '".$product->gender."' and client_target = '".$product->client_target."'")->orderByRaw(DB::raw("RAND()"))->take(3)->get();

But it not work. Please Help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire