如何从两个表中选择数据 [英] How to select data from two table

查看:88
本文介绍了如何从两个表中选择数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表A和B.both表有不同的数据,我想选择表格列,表格B为tabl A的每一行所有colmns。是否可能?



表A表B

------- ------

d1 1

d2 2

d3 3

d4 4

d5 5

d6 6

d7 7

d8 8

d9 9

d10 10

d11 11

d12 12

d13 13

d14 14

d15 15

d16 16

d17 17



这样的结果表我需要



表C

col1 col2

d1 1

d1 2

d1 3

d1 4

d1 5

d1 6

d1 7

d1 8

d1 9

d1 10

d1 11

d1 12

d1 13

d1 14

d1 15

d1 16

d1 17

d2 1

d2 2

d2 3

d2 4

d2 5

d2 6

..

..

..



就像这样它可以来,它只是示例otiginal数据将有更多1000行/ iwant一次性做

I have two Table A and B.both table having different data,i want to select table column with table B all colmns for each row of the tabl A.is it possible?

Table A Table B
------- ------
d1 1
d2 2
d3 3
d4 4
d5 5
d6 6
d7 7
d8 8
d9 9
d10 10
d11 11
d12 12
d13 13
d14 14
d15 15
d16 16
d17 17

result table like this i need

Table C
col1 col2
d1 1
d1 2
d1 3
d1 4
d1 5
d1 6
d1 7
d1 8
d1 9
d1 10
d1 11
d1 12
d1 13
d1 14
d1 15
d1 16
d1 17
d2 1
d2 2
d2 3
d2 4
d2 5
d2 6
..
..
..

like this it sould come,it is just example otiginal data will have more that 1000 rows/iwant to do in one shot

推荐答案

简单,

Simple,
SELECT col1,col2
FROM A,B





例如:



For example:

SELECT * FROM
(SELECT 'd1' as col1
UNION
SELECT 'd2') AS T1,
(SELECT 1 as col2
UNION
SELECT 2) AS T2
ORDER BY col1



结果:


Result:

col1	col2
d1	    1
d1	    2
d2	    1
d2	    2





希望,有帮助:)



Hope, it helps :)


这篇关于如何从两个表中选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆