0
查詢對我來說看起來非常正確。在查找時,查詢中似乎存在優先問題。'on子句'中的未知列
的問題是在這條線 - group_membership_settings.group_id = groups.id
未知列groups.id
'接通條款'
SELECT SQL_NO_CACHE `groups`.`name` AS `profile_name`, (
SELECT IF(
group_membership_settings.max_limit,
group_membership_settings.max_limit > (
SELECT COUNT(connection_memberships.id) FROM connection_memberships
WHERE connection_memberships.type = 'Connection::MenteeMembership'
AND connection_memberships.group_id = groups.id
), 1)
FROM programs
INNER JOIN roles ON roles.program_id = programs.id AND roles.name = 'student'
LEFT JOIN group_membership_settings ON group_membership_settings.group_id = groups.id AND group_membership_settings.role_id = roles.id
WHERE programs.id = groups.program_id
) AS `available_to_join` FROM `groups`