Get count of rows in table A that have a reference to table B

半腔热情 提交于 2019-12-02 11:35:52

Your SQL is correct for what you want to do. Slick is probably producing a query like this:

SELECT device.*, COUNT(device.id) 
-----------------------^
FROM device LEFT JOIN
     unit
     ON device.id = unit.device_id
GROUP BY device.id;

Maybe there is a way to get it to count device_id, which is unamibiguously from unit.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!