在聊天软件里friend表里就有两项useid和friendid,在另个一个表user里有用户信息,比如name,sex,age,我只有userid,想通过useid查到friend表里的内容,改怎么写呢

解决方案 »

  1.   

    select * from friend where userid =值friendid和user表有关系?不是很清楚两者之间的关系。
      

  2.   

    select *from friend where userid in(select userid from user where username='王明')
      

  3.   

    select *
    from friend A 
    Join user B On  A.userid=B.userid 
    where userid =123
      

  4.   

    3L:回答很给力啊,在一个地方时可以用的,效果不错但是在另一个地方就出错了
    select * from GROUP where GROUPid in(select GroupID from UserGroup where UserID=
    'B08030224')        ADO Error
            Code = 80040e14
            Code meaning = IDispatch error #3092
            Source = Microsoft OLE DB Provider for ODBC Drivers
            Description = [Microsoft][ODBC SQL Server Driver][SQL Server]关键字 'GRO
    UP' 附近有语法错误。
    有人知道什么什么原因吗
      

  5.   

    楼主肯定没写清楚要不就直接用1楼国哥的整个user表根本没得用。