select songname,username,content,state
from a,歌曲表,用户表
where a.userid=用户表.userid and a.songid=歌曲表.songid and state=1

解决方案 »

  1.   

    select b.songname , c.username , a.content
    from 留言内容 a
    left outer join 歌曲表 b on a.songid=b.songid
    left outer join 用户表 c on a.userid=c.userid
    where a.state=1
      

  2.   

    select b.songname , c.username , a.content
    from 留言内容 a
    left outer join 歌曲表 b on a.songid=b.songid
    left outer join 用户表 c on a.userid=c.userid
    where a.state=1用户表的数据都取不出来
      

  3.   

    create table tab_content
    (content_id int,
     userid int,
     songid int,
     state int, 
    content varchar(200),
     unique(content_id)
    )
    insert into tab_content values(1,1,1,1,'good')
    insert into tab_content values(2,2,1,1,'good too')
    insert into tab_content values(3,1,2,1,'good not')
    insert into tab_content values(4,2,2,1,'great')
    insert into tab_content values(5,2,1,0,'ok')
    insert into tab_content values(6,1,2,0,'aaaa')
    insert into tab_content values(7,1,2,0,'ffffffffffff')
    ---------------------------------------------
    create table tab_song
    ( songid int,
      songname varchar(50),
     unique(songid)
    )
    insert into tab_song values(1,'小城故事')
    insert into tab_song values(2,'雨一直下')
    ----------------------------------------------
    create table tab_user
    ( userid int,
      username varchar(50),
     unique(userid)
    )
    insert into tab_user values(1,'张三')
    insert into tab_user values(2,'李四')
    ----------------------------------------------
    select b.songname , c.username , a.content
    from tab_content a
    left outer join tab_song b on a.songid=b.songid
    left outer join tab_user c on a.userid=c.userid
    where a.state=1
    --结果
    songname   username   content
    小城故事   张三    good
    小城故事   李四    good too
    雨一直下   张三    good not
    雨一直下   李四    great--  楼主,绝对没有问题
    --  一定是你搞错了
    --  不信你试验一下
      

  4.   

    仔细查询一下你关联的字段对不对,,
    顺便说一下
    lw1a2 的回答有问题
    内联 会出现错误