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

yayuj's avatar

Merge tables results and sort them

I watched a video here on Laracasts that @JeffreyWay made an example of that, merging results in a route called /all, but I don't remember which one was. Anyhow, even though there's this lesson (I want to remember if you know), I want to sort the results as, for example, imagine that I have three tables, Foo, Bar, Biz, and the result would be like that.

Foo Bar Biz
Foo Bar Biz
Foo Bar Biz

Instead of

Foo Foo Foo
Bar Bar Bar
Biz Biz Biz

How can I do this? and is it even possible?

And I would like to paginate as well.

0 likes
1 reply
bestmomo's avatar

You must use mySql CONCAT command.

In SQL something like that :

SELECT CONCAT(foo.name, bar.name, biz.name)
FROM foo
JOIN bar ON (foo.id = bar.id)
JOIN biz ON (foo.id = biz.id)

Please or to participate in this conversation.