---
title: "exists"
author: "heyafang"
date: "2014-09-02T11:42:28Z"
tags: []
categories: ["数据库"]
slug: "exists"
draft: false
lastmod: "2014-09-02T11:42:28Z"
id: 2112014
url: "https://zenman.iteye.com/blog/2112014"
---

```
select count(*) from NetTeacherStudent as nts where exists(select id from NetTeacher as nt where nt.user.username='"+username+"' and nts.teacher.id=nt.id)
```