一句sql不知道怎么写
时间:2011-11-19
来源:互联网
表1 字段 a,b,c
表2 字段 d,e,f
表2的e,f字段存的是表1的a
现在要读
表2.e=表1.a 的表1的所有字段数据
表2.f=表1.a 的表1的所有字段数据
还有 对应的表2的字段数据
用一句sql
不知道表达清楚了没
表2 字段 d,e,f
表2的e,f字段存的是表1的a
现在要读
表2.e=表1.a 的表1的所有字段数据
表2.f=表1.a 的表1的所有字段数据
还有 对应的表2的字段数据
用一句sql
不知道表达清楚了没
作者: csrr2012 发布时间: 2011-11-19
SQL code
select a.*,b.* from tb1 a join (select d,e from tb2 union select d,f from tb2) b on a.a=b.e
作者: josy 发布时间: 2011-11-19
SQL code
select * from tb2 a join tb1 b on a.e = b.a join tb1 c on a.f = c.a
作者: AcHerat 发布时间: 2011-11-19
不行就换left join。
作者: AcHerat 发布时间: 2011-11-19
SQL code
select a.*,b.* from t1 a inner join t2 b on a.a=b.e or a.a=b.f
作者: qianjin036a 发布时间: 2011-11-19
SQL code
create table t1(a int,b int,c int) insert into t1 select 1,234,534 insert into t1 select 2,324,439 insert into t1 select 3,94,9438 insert into t1 select 4,843,92 insert into t1 select 5,985,894 create table t2(d varchar(10),e int,f int) insert into t2 select 'aaa',2,19 insert into t2 select 'bbb',5,33 insert into t2 select 'ccc',10,4 go select a.*,b.* from t1 a inner join t2 b on a.a=b.e or a.a=b.f /* a b c d e f ----------- ----------- ----------- ---------- ----------- ----------- 2 324 439 aaa 2 19 5 985 894 bbb 5 33 4 843 92 ccc 10 4 (3 行受影响) */ go drop table t1,t2
作者: qianjin036a 发布时间: 2011-11-19
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28