Level 73
Those records are not duplicate since the rollnum is not the same and the id makes it complex.
If the were the same you could use distinct.
SELECT DISTINCT name, age FROM table;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey folks, I'm stuck-up with query builder. I wanna merge duplicate column values into one row.
for example I have
id name age rollnum
1 bob 24 null
2 bob 24 1234
i wanna see 1 bob 24 1234. How can i do that in below query. Any help that would be appreciated. Thanks in advance.
`//Query Builder
$data = \DB::table("table1 AS a")
->select("a.*")
->join(\DB::raw("(SELECT
id, name, age, COUNT(*),
FROM table2
GROUP BY b.name, b.age
HAVING count(*) > 1
) as b"), function($join){
$join->on("a.name", "=", "b.name")->on("a.age", "=", "b.age")->on("a.id", ">", "b.id");
})
->orderBy("a.name")
->get();
`
Please or to participate in this conversation.