select * from (select top 1 a from A) a,(select top 1 b from B where xx='xx') b的问题
1   select   *   from   (select   top   1   a   from   A)   a,(select   top   1   b   from   B   where   xx= 'xx ')   b       
 a               b 
 1               2          
 (select   top   1   a   from   A)   a   总有记录 
 (select   top   1   b   from   B   where   xx= 'xx ')   b       
       它如果没有记录的话,语句1也不出来记录,,这是咋回事泥
------解决方案--------------------帮顶
------解决方案--------------------语句1是用的迪卡尔积,需要两个表都有数据才行.
------解决方案--------------------帮顶 
------解决方案--------------------where xx= 'xx '--条件不满足没记录
------解决方案--------------------(select top 1 b from B where xx= 'xx ') b 
 它如果没有记录的话,语句1也不出来记录,,这是咋回事泥 
 ---------------------- 
 现在说的是上述查询没有结果时第一个语句也没有结果的问题.
------解决方案--------------------从2个表中提取数据吗? 
 要是从2个表里提取数据,需要有一个记录关联项?   
 (SQL不会,如果错了,就当作没看见好了)
------解决方案--------------------select top 1 a from A--只要表里有记录都满足
------解决方案--------------------因为这个语句是内连接,所以如果b没有记录就不会出来记录   
 要达到b没记录也能出来记录,可以这样做: 
 select * from (select top 1 a from A) a 
 left outer join (select top 1 b from B where xx= 'xx ') b
------解决方案--------------------用左连试一试。
------解决方案--------------------对不起,上面语句错误: 
 正确应该的是: 
 select * from (select top 1 a from A) a 
 left outer join (select top 1 b from B where xx= 'xx ') b 
 on 1= 1