想册表(photoid,userid,jd_id)主键是photoid;
jd_id(以逗号,隔开的景点ID列表)景点表(jd_id,jd_name)主键是jd_id求用户ID为10031拥有的想册分别对应的景点名称?

解决方案 »

  1.   

    select a.userid, a.photoid ,b.jd_name from 相册表 a, 景点表 b where  INSTR(a.jd_id,b.jd_id) <> 0;
      

  2.   

    上面没有id的条件,补上:
    select a.userid, a.Id ,b.jd_name from 相册表 a, 景点表 b 
       where  INSTR(a.jd_id,b.jd_id) <> 0 and a.userid=10031;
      

  3.   

    SELECT 
      A.jd_name
    FROM 
      景点表 A,
      相册表 B
    WHERE 
      LOCATE(CONCAT(',',A.jd_id,','),B.jd_id)>0
    AND 
      B.userid='10031'
      

  4.   


    试下:select a.photoid,a.userid,b.jd_name 
    from 想册表 a, 景点表 b 
    where a.userid=10031 and find_in_set(b.jd_id,a.jd_id)>0;
      

  5.   

    这得用存储过程 
    将每个jd_id 分别循环取出来
    s然后查询
      

  6.   

    select distinct b.jd_name
    from 想册表 a , jd_id b
    where FIND_IN_SET(b.jd_id,a.jd_id) 
    and userid=10031当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html