---
# System prepended metadata

title: SQL

---

# SQL

```sql=
select user from enroll join user on enroll.user_id = user.id where enroll.class_id = `classid`
```


```haskell=
joinWhere1 
  :: EntityFieldWrapper user row1 ty 
  -> EntityFieldWrapper user row2 ty
  -> Filter user row1
  -> TaggedT user m [(Entity row1, Entity row2)]
  
    act = E.select $ E.from $ \(r1 `E.InnerJoin` r2) -> do
            E.on $ r1 E.^. f1 E.==. r2 E.^. f2 
            E.where_ (toSqlQuery filter1)
            return (r1, r2)  
  
  
```




```haskell=
-- clsId <- ...

enroll_users <- joinList EnrollUserId UserId (EnrollClassId ==. clsId)
-- enroll_users' <-
--   filterM (\enroll_user -> do 
--     cid' <- project EnrollClassId (fst enroll_user) 
--     return (cid' == clsId)
--   ) enroll_users
groups   <- selectList notFoundJSON (groupClass' ==. clsId)

```