Query users with multiple devices (MySQL)

coaty_obrien
New Contributor II

If you're looking for additional ways to solve unique problems like I was, I highly suggest setting up a read-only account to access the JAMF database via MySQL Workbench. In my case, our databases are handled by another team and I would normally have to bug someone else to run updates or queries during support cases.

One of the benefits of this is to create custom queries that you cannot run via search.  If you're in need of identifying which users have multiple devices & the number of devices they have, along with some device info, hopefully this post/query will save you some time.

If you query the table you can pull out additional fields if needed. ( select * from computers_denormalized) or (select * from mobile_devices_denormalized) just add the additional fields to top select line.

We're running JAMF Pro version 10.35.0

Identifying users with multiple computers:

select username,email,serial_number,model,number_of_devices
from
(
select
username,
COUNT(username) as number_of_devices
from computers_denormalized
group by username,email
having COUNT(username) > 1
)
as t
inner
join computers_denormalized
using (username);

Identifying users with multiple mobile devices:

select username,email,serial_number,model,iccid,imei,meid,number_of_devices
from
(
select
username,
COUNT(username) as number_of_devices
from mobile_devices_denormalized
group by username,email
having COUNT(username) > 1
)
as t
inner
join mobile_devices_denormalized
using (username);

0 REPLIES 0