现在有两个表,第一张表是这样
tale1
id name sex
1 n1 男
2 n2 男
3 n3 女
table2
id name
1 张三
select * from table 得到表一,select * from table2得到表二,我想得到这样的结果,如何弄:
1 n1 男 1 张三
2 n2 男 1 张三
3 n3 女 1 张三
就是把表二的一行全部加到表一的每一行中。如何搞,多谢。
tale1
id name sex
1 n1 男
2 n2 男
3 n3 女
table2
id name
1 张三
select * from table 得到表一,select * from table2得到表二,我想得到这样的结果,如何弄:
1 n1 男 1 张三
2 n2 男 1 张三
3 n3 女 1 张三
就是把表二的一行全部加到表一的每一行中。如何搞,多谢。
解决方案 »
- 创建表空间三行代码,为什么就出错(琢磨一小时了)
- 紧急问题
- oracle_10g_home中写了个函数,编译出错,大家帮忙看下,谢谢!
- hibernate的Union怎么使用??????????????????????????????
- 關於PL/SQL中SQL Window中寫命令的問題.
- 怎么在不同的几个城市共享一个数据库!请帮忙给点建议!谢谢!
- 谁能提供一些ORACLE中交叉报表的示例!!
- oracle 注册表问题 大虾请进
- 通过pl/sql可以返回结果集吗?
- oracle数据Oracle Net Configuration Assistant配置问题
- 急!!!急!!!求救!!!在线等!!!!
- 为什么停止OracleDBConsole服务,数据库就变快了
select 1 id,'n1' name,'男' sex from dual
union all
select 2 id,'n2' name,'男' sex from dual
union all
select 3 id,'n3' name,'女' sex from dual
),table2 as(
select 1 id,'张三' name from dual
)select * from table1,table2结果:
1 1 n1 男 1 张三
2 2 n2 男 1 张三
3 3 n3 女 1 张三
select * from table1,table2;我试过可以,请楼主放心!!!
with table1 as (
select 1 id,'n1' name, '男' sex from dual union all
select 2 id,'n2' name, '男' sex from dual union all
select 3 id,'n3' name, '女' sex from dual),
table2 as(
select 1 id, '张三' name from dual)
select a.id,a.name aname,a.sex,b.id,b.name bname from table1 a,table2 b;