宋利兴__2011/09/13
select[distinct]列名….from表名
注意事项
可以替代列名, 表示所有列, 但是通常我们为了提高代码的可读性, 不使用*
DISTINCT为过滤重复记录
1. 表的设计
1.1. 单独的实体
public class User{
private int id;
private String name;
private int age;
}
user
id
name
age
1
张三
18
2
李四
20
3
王五
19
1.2. 一对多、多对一
foreign key
public class Employee {
private int id;
private String name;
private Department department;
}
public class Department {
private int id;
private String name;
private Set employees;
}
一对多
多对一
department employee
id
name
1
开发部
2
市