Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jije's avatar
Level 1

Query builder - Distinct rows (with multiple columns)

Hello. I want to make query with Query Builder for returning rows with distinct columns. For example:

SELECT  
    DISTINCT ip,
    DATE(FROM_UNIXTIME(unix_time)),
    location_id  
FROM test_table

This MySQL query returns unique triples from test_table for each day. But i could not do it with Laravel/Lumen Query Builder. Thank you in advance!

NOTE: I use mongoDB.

0 likes
1 reply
Tomi's avatar

´$query->selectRaw('distinct(id)');´

Please or to participate in this conversation.