select a.* from a, b where a.sphonid=b.sphonid and b.p_times=3
declare @p_times int set @p_times= 2 select a.* from ta,tb b where a.sphoneid=b.sphoneid and b.p_times=@p_timesselect * from a where esphonid in (select esphonid from b where p_times = @p_times )
SELECT 1.sphonid , 1. 地址 FROM A 1 INNER JOIIN B 2 ON 1 sphonid = 2 sphonid
SELECT 1.sphonid , 1. 地址 FROM A AS 1 INNER JOIN B AS 2 ON 1.sphonid = 2.sphonid
select a.p_times,a.* from ta,tb b where a.sphoneid=b.sphoneid order by a.p_times
declare @p_times int
set @p_times=123
select a.* from ta,tb b where a.sphoneid=b.sphoneid and b.p_times=@p_times
declare @p_times int
set @p_times=2
select a.* from ta,tb b where a.sphoneid=b.sphoneid and b.p_times=@p_times
我现在要做的是 b表中的p_times是中奖期数,而sphoneid是该期的中奖号码
我要根据中奖期数去a表中找出这个号码的中奖地址
from a, b
where a.sphonid=b.sphonid
and b.p_times=3
set @p_times= 2
select a.* from ta,tb b where a.sphoneid=b.sphoneid and b.p_times=@p_timesselect * from a where esphonid in (select esphonid from b where p_times = @p_times )
FROM A 1 INNER JOIIN B 2
ON 1 sphonid = 2 sphonid
FROM A AS 1 INNER JOIN B AS 2
ON 1.sphonid = 2.sphonid
from ta,tb b where a.sphoneid=b.sphoneid
order by a.p_times