不知道mysql应该是怎么搞的
sql server 中这么搞才可以
你那样不行看看到现在没有人回答
我就用sql server 写了一下
你参考一下吧   新年快乐
------------------------------------------
create  table #user(id int ,shopid varchar(10))
insert into #user
select 1 , '1,2,3'create  table #shop(shopid int , shopName varchar(10))
insert into #shop
select 1 ,'aa'
union select 2 ,'bb'
union select 3 ,'cc'declare @sql varchar(20)
select @sql = shopid  from #user where id =1
set @sql = 'select * from #shop where shopid in ('+@sql+')'
exec(@sql)/*
shopid   shopname
---------------------
1   aa
2   bb
3   cc*/--删除测试数据
drop table #user
drop table #shop

解决方案 »

  1.   

    你再试试这个 mysql 的语句select a.* from shop a ,user b 
    where b.id = 1 and INSTR(b.shopid, a.shopid);
      

  2.   

    1、mysql4.1开始才支持子查询。2、select * from shop where shopid in (select shopid from user)
    作为调试如下:
    先判断:select shopid from user 能返回几条记录。
      

  3.   

    7-晕,首先我的MYSQL肯定是支持子查讯,其实就是这样:
    这句分成两句的:
    先select shopid from user where id=1
    得出shopid='1,2,3'
    然后select * from shop where shopid in ($shopid)这样就可以得出3条记录,可把两句合并怎么就不行了呢
      

  4.   

    谢谢小辉的这句,取得的结果正确,但不知我那句有什么问题
    select a.* from shop a ,user b 
    where b.id = 1 and INSTR(b.shopid, a.shopid);
    明晚来结贴了