select UserProperty.PropertyName,UserProperty.UserClassID,UserProperty.PropertyType,UserPropertyValue.* from UserProperty left join UserPropertyValue on UserProperty.UserClassID in (1,2,3) and UserProperty.PropertyID=UserPropertyValue.PropertyID and UserPropertyValue.UserID='wujiabin' 

解决方案 »

  1.   

    我不习惯用join ,下面的程序看看能用不:
    select    UserProperty.PropertyName,UserProperty.UserClassID,UserProperty.PropertyType
    from 
        UserProperty.UserClassID*=UserPropertyValue.UserClassID and --不知道是否以  
                                                             --UserClassID为连接字段?
        UserProperty.UserClassID=1 and  UserProperty.PropertyID=UserPropertyValue.PropertyID and UserPropertyValue.UserID='wujiabin' 
      

  2.   

    误会了
    我的意思的
    我的 sql语句 与
    你写的sql,得到的结里是一样的呀
    应该不同呀
      

  3.   

    刚刚没看清楚,连接条件应该是 PropertyID吧?
    select    UserProperty.PropertyName,UserProperty.UserClassID,UserProperty.PropertyType
    from    
        UserProperty.PropertyID*=UserPropertyValue.PropertyID and 
        UserProperty.UserClassID=1 and    
        UserPropertyValue.UserID='wujiabin' 
      

  4.   

    你是不是要显示表UserProperty的符合条件的所有记录和UserPropertyValue的符合的记录?
    要显示UserProperty.UserClassID=2或3,还是不要?
    要就要去掉条件:
    UserProperty.UserClassID=1 
      

  5.   

    我是要显示 UserProperty.UserClassID=1 
    的记录

    是结果 UserProperty.UserClassID=2 or 3 的记录来出来的这条件好像没有起作用呀
      

  6.   

    不会呀,我这里显示结果正常,只出现UserProperty.UserClassID=1 的结果
    你再检查一下,ID不是数字就加个''号试试
      

  7.   

    select  
          UserProperty.PropertyName,UserProperty.UserClassID,UserProperty.PropertyType
    from   UserProperty,UserPropertyValue
    where  UserProperty.PropertyID*=UserPropertyValue.PropertyID and 
           UserProperty.UserClassID=1 and    
           UserPropertyValue.UserID='wujiabin'
      

  8.   

    是的,对了,UserProperty.PropertyID*=
    的*号是什么意思呀。
      

  9.   

    select UserProperty.PropertyName,UserProperty.UserClassID,
           UserProperty.PropertyType,
           UserPropertyValue.* 
    from UserProperty left join UserPropertyValue 
    on UserProperty.PropertyID=UserPropertyValue.PropertyID 
    where UserProperty.UserClassID=1 
        and UserPropertyValue.UserID='wujiabin'
      

  10.   

    To:
    这个语句 不灵,结果不对呀.select UserProperty.PropertyName,UserProperty.UserClassID,
           UserProperty.PropertyType,
           UserPropertyValue.* 
    from UserProperty left join UserPropertyValue 
    on UserProperty.PropertyID=UserPropertyValue.PropertyID 
    where UserProperty.UserClassID=1 
        and UserPropertyValue.UserID='wujiabin'