select * from a  where exists (select * from b where a.sphonid = b.sphoneid)

解决方案 »

  1.   

    --try
    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
      

  2.   

    --try
    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
      

  3.   

    你好,不知道是不是我理解错误,你的sql语句感觉不是我要的.
    我现在要做的是 b表中的p_times是中奖期数,而sphoneid是该期的中奖号码
    我要根据中奖期数去a表中找出这个号码的中奖地址
      

  4.   

    select a.*
    from a, b
    where a.sphonid=b.sphonid
    and b.p_times=3
      

  5.   

    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 )
      

  6.   

    SELECT 1.sphonid , 1. 地址
    FROM A 1  INNER JOIIN  B 2
    ON 1 sphonid = 2 sphonid
      

  7.   

    SELECT 1.sphonid , 1. 地址
    FROM A AS 1  INNER JOIN  B AS 2
    ON 1.sphonid = 2.sphonid
      

  8.   

    select a.p_times,a.* 
    from ta,tb b where a.sphoneid=b.sphoneid 
    order by a.p_times