三个表如何关联,以及关联顺序 还有如果select 这个col取哪个表的col比较好? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我的答案是select c.col.....where c.col = b.col and c.col = a.col;顺便再问一下oracle中where以后的执行顺序是从后往前的,该怎么利用这个条件? select * from Awhere A.col in(select B.col from B,C where B.col = C.col) sorry,我忘记说了,我因为要取b和c的数,所以得 from a,b,c 关键是(记录数A远大于B远大于C) select C.col,A.aaa,B.bbbfrom C join A on A.col = C.coljoin B on B.col = C.col 这样怎么样?select c.col.....where c.col = b.col and c.col = a.col; 建议拿测试工具测一下(用你的大数据量)感觉你的这种方式,是把C和B有关系的取出来,C和A有关系的再取出来,然后再把两者的结果再进行比较,来取值!而Join方式呢,把C和A有关系的取出来之后,再到B中去找符合条件的!还是用测试出来的数据来说比较好! 我的答案是select *from a join c on a.col = c.col join b a.col = b.col我感觉应该先用最大的表和最小的表产生结果集然后在和中间的表进行比较 我的测试结果SQL> select count(1) 2 from an_user_base_file a 3 join an_measure_pos b 4 on a.user_no = b.user_no 5 where a.bureau_code = '00' 6 / COUNT(1)--------- 158773 real: 8563SQL> select count(1) 2 from an_user_base_file a ,an_measure_pos b 3 where a.user_no = b.user_no 4 and a.bureau_code = '00' 5 / COUNT(1)--------- 158773 real: 11750SQL> select count(1) 2 from an_user_base_file a 3 join an_measure_pos b 4 on a.user_no = b.user_no 5 where a.bureau_code = '00' 6 / COUNT(1)--------- 158773 real: 10953SQL> select count(1) 2 from an_user_base_file a ,an_measure_pos b 3 where a.user_no = b.user_no 4 and a.bureau_code = '00' 5 / COUNT(1)--------- 158773 real: 8250SQL> select count(1) 2 from an_user_base_file a 3 join an_measure_pos b 4 on a.user_no = b.user_no 5 where a.bureau_code = '00' 6 / COUNT(1)--------- 158773 real: 7891SQL> 求助大虾关于数据库的ER图知识。 把表1中的字段值转为表2的字段 问道SQL的小问题 一个小问题 表格数据查询 SQL Server 2000中创建登录帐号 mssql 动态的拼接字符串不成功 是不是我的申明有问题? 一个SQLSERVER2000的问题!!!!!!! imp ? 成功终止导入,但出现警告??? 怎么在sql server中写函数!? 求sql语法,请进 海量售票数据如何保存的问题,请有经验的给予指导,谢谢,不胜感激!
select c.col.....where c.col = b.col
and c.col = a.col
;顺便再问一下oracle中where以后的执行顺序是从后往前的,该怎么利用这个条件?
where A.col in
(select B.col from B,C where B.col = C.col)
from C join A on A.col = C.col
join B on B.col = C.col
and c.col = a.col
;
select *
from a join c on a.col = c.col join b a.col = b.col我感觉应该先用最大的表和最小的表产生结果集然后在和中间的表进行比较
2 from an_user_base_file a
3 join an_measure_pos b
4 on a.user_no = b.user_no
5 where a.bureau_code = '00'
6 / COUNT(1)
---------
158773 real: 8563
SQL> select count(1)
2 from an_user_base_file a ,an_measure_pos b
3 where a.user_no = b.user_no
4 and a.bureau_code = '00'
5 / COUNT(1)
---------
158773 real: 11750
SQL> select count(1)
2 from an_user_base_file a
3 join an_measure_pos b
4 on a.user_no = b.user_no
5 where a.bureau_code = '00'
6 / COUNT(1)
---------
158773 real: 10953
SQL> select count(1)
2 from an_user_base_file a ,an_measure_pos b
3 where a.user_no = b.user_no
4 and a.bureau_code = '00'
5 / COUNT(1)
---------
158773 real: 8250
SQL> select count(1)
2 from an_user_base_file a
3 join an_measure_pos b
4 on a.user_no = b.user_no
5 where a.bureau_code = '00'
6 / COUNT(1)
---------
158773 real: 7891
SQL>