Joining a table on an id but need to copy this data to other ids
SELECT d.id deviceid, u.id userid, dp.preferenceid
FROM Users u, Devices d, Device_Preference dp
WHERE u.id = dp.userid
  AND u.id = d.userid
ORDER BY 1,3


fiddle