sql中的join
来源:互联网 发布:json格式转换工具类 编辑:程序博客网 时间:2024/06/03 17:07
---------------------------------题记
在使用hibernate的hql区分隐式(implicit)与显式(explicit)关联的时候,根据show_sql的语句,在数据库做了一下简单的测试,以加深印象。其中如下查询语句中1为隐式查询(如:hql 'from student s where s.class.id=s.id'),2、3、4为显式查询(如:hql 'from student s join class c on c.id=s.id')。在hibernate3.2.3以后的版本不支持1-n、n-n,单个实体和组件依然有效。
---------------------------------代码
create table t_temp_student( pk_id int primary key not null, f_name varchar(20), f_age int, fk_class_id int);create table t_temp_class( pk_id int primary key not null, f_name varchar(20));insert into t_temp_class values(1,'一班');insert into t_temp_class values(2,'二班');insert into t_temp_class values(3,'三班');insert into t_temp_student values(1,'张学友',10,1);insert into t_temp_student values(2,'刘德华',11,1);insert into t_temp_student values(3,'黎明',10,2);insert into t_temp_student values(4,'郭富城',9,2);insert into t_temp_student values(5,'陈冠希',5,4);-- 下列1、2、3句效果相同(除cross join,其他必须携带on,即join是inner join的简写)select * from t_temp_student s cross join t_temp_class c where s.fk_class_id = c.pk_id;-- 关联属性只能携带在where后面,不能有on,也可以没有whereselect * from t_temp_student s inner join t_temp_class c on s.fk_class_id = c.pk_id; -- 不能没有onselect * from t_temp_student s join t_temp_class c on s.fk_class_id = c.pk_id;-- 不能没有onselect * from t_temp_student s left join t_temp_class c on s.fk_class_id = c.pk_id; -- 不能没有on,且left join左侧数据全部列出,若不满足on,则left join左侧数据对应的右侧数据为null
- sql中的join、left join、right join
- SQL中的JOIN
- SQL中的各种join
- sql 中的join
- sql中的join
- sql中的join
- sql中的join 使用
- SQL中的join连接
- sql中的join语句
- SQL中的join连接
- sql 中的各类join
- SQL中的各种Join
- sql 中的join方式
- SQL中的JOIN
- sql中的join
- SQL中的left join right join
- sql中的 inner join 和 out join
- SQL中的各种JOIN(inner join,full outer join,left join,right join,cross join )
- linux 网络子系统之----TCP基础协议
- strncat函数实现
- ArcMap 无法启动
- 第一节 与SDL第一次亲密接触
- 不调用字符串库函数,实现字符串复制函数
- sql中的join
- 写文档的经验教训
- c# 读取opencv 生成的svm训练好的xml分类器
- memset简单实现
- 移动物联智慧科技:移动应用案例
- 堆排序
- 自己可能用到的笔试面试题(整理C/C++)
- 使用chmod同时给目录、文件夹赋予不同的权限
- 微信公众账号运营培训内部教程