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

LaraBABA's avatar

Is there a way to query a pivot table in the DB builder(Not eloquent)

Hello,

I am looking at the doc and I cannot find a way in the DB query pages to get the data from a pivot table. Any idea how to do this please?

Is there not something like ->wherePivot(tablename, id, id) ?

Thank you.

0 likes
3 replies
LaraBABA's avatar

I am wondering if the "Union" would not be the way forward with the DB query?

LaraBABA's avatar

Thanks, I see, so the pivot can be accessed without any issues with a join....interesting.

Thanks again.

Please or to participate in this conversation.