日期:2014-05-18  浏览次数:20568 次

SQL select 语句 ,在线等!!!!
数据库中两张表,表aa 有两列 boxid 和 sn ,其中一个boxid对应多个sn, sn是唯一的,在另一张表bb 中item ,wonum ,sn三列,我现在要根据boxid查出aa中的sn,然后将bb中的sn对应的item,wonm显示出来sql 语句如下
Select a.*,b.Item,b.WoNum From aa a inner join bb b on a.BoxID = 'Wo_box_2' and b.sn=(select sn from aa)
报错为:Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
请问sql语句该怎么写??????

------解决方案--------------------
Select a.*,b.Item,b.WoNum From aa a inner join bb b on a.BoxID = 'Wo_box_2' and b.sn in(select sn from aa)
------解决方案--------------------
SQL code
Select a.*,b.Item,b.WoNum From aa a 
inner join bb b on a.BoxID = 'Wo_box_2' 
and b.sn=a.sn

------解决方案--------------------
select a.*,b.item,b.wonum from aa as a join bb as b on a.sn=b.sn where a.boxid='Wo_box_2'
------解决方案--------------------
SQL code
Select a.*,b.Item,b.WoNum 
From aa a inner join bb b 
on a.BoxID = 'Wo_box_2' and a.sn = b.sn

------解决方案--------------------
Select *,b.Item,b.WoNum From aa inner join bb as b on aa.BoxID = 'Wo_box_2' and aa.sn=bb.sn
 
 
回答的第一个,第二个,我写错了,看第三个,