scinote-web/db/views/datatables_teams_v01.sql

14 lines
397 B
MySQL
Raw Normal View History

SELECT
teams.id AS id,
teams.name AS name,
user_teams.role AS role,
(
SELECT COUNT(*)
FROM user_teams
WHERE user_teams.team_id = teams.id
) AS members,
2017-11-03 17:11:23 +08:00
CASE WHEN teams.created_by_id = user_teams.user_id THEN false ELSE true END AS can_be_left,
user_teams.id AS user_team_id,
user_teams.user_id AS user_id
FROM teams INNER JOIN user_teams ON teams.id=user_teams.team_id