http://topic.csdn.net/u/20110507/15/975df145-20b3-4065-ac6b-d3b4cfb3a52f.html求解惑。

解决方案 »

  1.   

    看了你的 on 后面的条件为等于然后在把结果当一张表在近一步用in 查
      

  2.   

    你得把orderList 这个a,b拆开来才能查,in不认识这样的 
      

  3.   

    刚仔细看了一遍可能要应用拆分函数把orderList 拆分 
    1 a 
    1 b这样的形式在进行join 查询
      

  4.   


    --楼主可以直接运行
    declare @orderInfo table (orderNum varchar(1),Product varchar(5))
    insert into @orderInfo
    select 'a','商品1' union all
    select 'b','商品2'declare @ExpressOrder table (ID int,orderList varchar(6))
    insert into @ExpressOrder
    select 1,'a,b'select a.ID,orderNum ,product,orderNum from @ExpressOrder a
    right join @orderInfo b
    on charindex(','+b.orderNum+',',','+a.orderList+',')>0/*
    ID          orderNum product orderNum
    ----------- -------- ------- --------
    1           a        商品1     a
    1           b        商品2     b
    */