Table A: id,name
1, Taylor
2, Jim
Table A_attr: id,item,value
1, 身高,175
1, 体重,65
我用: select a.name from a,a_attr where a.id=a_attr.id
结果: Taylor
Taylor
能得到2条, 而我想要的是只要一条, 我能想到的用distinct,但是限于其他原因最好不使用distinct,
请教还有其他的写法吗! 谢谢!
1, Taylor
2, Jim
Table A_attr: id,item,value
1, 身高,175
1, 体重,65
我用: select a.name from a,a_attr where a.id=a_attr.id
结果: Taylor
Taylor
能得到2条, 而我想要的是只要一条, 我能想到的用distinct,但是限于其他原因最好不使用distinct,
请教还有其他的写法吗! 谢谢!
解决方案 »
- 考虑到表频繁地插入和删除记录的情况,用序列(SEQUENCE)创建的主键值可以重复利用么?
- 用sql语句插入clob字段
- 求一个SQL语句(分组后求最大最小值的条数)
- 请教一个SQL查询语句怎么写
- 在线等oracle9i中建立函数是否可以用数组作为参数,如果可以,如何处理……在线等
- Oracle 9i 可以编写面向对象格式的结构吗?
- 求教一个简单的问题
- 送分了```
- 嵌套查询和连接的区别?????????????????
- 如何将Sql Server数据导入Oracle数据库中,百分求解,在线等待!
- 本人是oracle初学者,用jsp连接时出现ORA-01017: invalid username/password; logon denied错误
- 11个,为什么我建立的JOB不自动运行?
--这样就是一条了
select name from a where exists(select * from A_attr where a.id=a_attr.id);
with a as(
select 1 id,'Taylor' name from dual
union all
select 2,'Jim' from dual
),a_attr as(
select 1 id,'身高' item,175 value from dual
union
select 1,'体重',65 from dual
)
select name from a where exists (select 1 from a_attr where id = a.id)NAME
------
Taylor