Support the ongoing development of Laravel.io →
posted 10 years ago
Database
Last updated 2 years ago.
0

you may want to look at the count() method from the aggregates section at:

http://laravel.com/docs/queries#aggregates

Last updated 2 years ago.
0

@jgarifuna sorry that doesn't work, that still returns the first result which unfortunately is wrong for example the query above returns:

| COUNT(*) |
| 1          |
| 1          |
| 1          |
| 1          |
| 4          |
| 1          |
Last updated 2 years ago.
0

I have managed to get this.

select count(*) as `count` from (select
	COUNT(*)
from `mortgages`
inner join `cases` on `mortgages`.`case_id` = `cases`.`id`
inner join `cases_timeline` on `cases_timeline`.`case_id` = `cases`.`id`
where
	`mortgages`.`user_id` in (7)
	and
	`cases_timeline`.`event_id` in (11)
GROUP BY `mortgages`.`id`) sq
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

bweston92 bweston92 Joined 3 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.