select good_id from order_table,good_table  
where order_table.order_goodlist like '%'+str(good_id)+'%'  
加上
group by good_id 试试

解决方案 »

  1.   

    select good_id from good_table  
    where good_id in (select order_goodlist from order_table)
      

  2.   

    select good_id from order_table,good_table  
    where charindex(@goodid,order_table.order_goodlist)>0
      

  3.   

    更正主题:应该是
    select count(order_id) from order_table,good_table  
    where order_table.order_goodlist like '%'+str(good_id)+'%' 
    主题上的不对。希望各位帮忙,谢谢!
      

  4.   

    我已经发出了问题应该将
    '%'+str(good_id)+'%' 
    改成 
    '%'+CONVERT(varchar(6),good_id)+'%'
    就可以了。
    不过还是要谢谢大家如此热心,散分! 
      

  5.   

    我觉得你这个订单表设计的有问题,为什么要把一个ORDER_id和他的所有的定购商品要放在一行了,按你上面的做法,如果某一次定购定购了数量在两个以上的同一个商品,那该怎么办呢?按你的想法,可能是说我在GOOD_LIST里面重复写多个同一个商品的ID不就行了,那么上面的这些方法都不行,因为只涉及到商品,而没有考虑数量,而你自己想去取商品的定购数量
    这里肯定有问题