quyle92 liked this thread
This seems work for me...What were you trying to do?
DB::statement(DB::raw('SET @total = "bar"'));
$a = DB::select(DB::raw('select * from applications where foo = @total'));
DB::statement(DB::raw('SET @total = "id"'));
$b = DB::select('select @total from applications');
quyle92 liked this reply
There's inline initializing available in MySQL:
DB::select(DB::raw('@total := @total + x as total_x'), ...)
->from(DB::raw('your_table, (select @total := 0) as var'))
...
->get();
quyle92 liked this reply
could you help me to put this query in laravel
SET @prev=0,@rownum=0;
SELECT utilizador_id, nome
FROM (SELECT *,
IF( @prev <> utilizador_id,
@rownum := 1,
@rownum := @rownum+1
) AS rank,
@prev := utilizador_id,
@rownum
FROM ( SELECT * FROM anuncios
ORDER BY utilizador_id, rand()
) random_prodcts
) products_ranked
WHERE rank <= 2
thanks in advance
quyle92 liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community