数据表1
create table a
(
id int,
times int,
)
(
id int,
times int,
)
数据表2
create table b
(
id int,
rid int,
)
go
(
id int,
rid int,
)
go
查询表1
select * from b
select * from b
结果:
id rid
1 1 11
2 2 22
3 3 33
查询表2
select * from a
select * from a
结果:
id rid
1 1 1
2 2 2
3 3 3
查询表的所有内容
SELECT A1.id ,
A1.times,
B1.id,
B1.rid
FROM
( SELECT ROW_NUMBER() OVER ( ORDER BY id ) id ,times FROM a)A1
FULL JOIN
( SELECT ROW_NUMBER() OVER ( ORDER BY id ) id ,rid FROM B)B1 ON A1.id = B1.id
WHERE b1.id=1
A1.times,
B1.id,
B1.rid
FROM
( SELECT ROW_NUMBER() OVER ( ORDER BY id ) id ,times FROM a)A1
FULL JOIN
( SELECT ROW_NUMBER() OVER ( ORDER BY id ) id ,rid FROM B)B1 ON A1.id = B1.id
WHERE b1.id=1
结果:
id times id rid
1 1 1 1 11