查看留言:select * from gb,attachment where gb.id=attachment.id and attachment.isre='NO'

解决方案 »

  1.   

    查看某条留言的回复:select * from attachment where id=留言ID and attachment.isre='yes'
      

  2.   

    楼上的朋友理解错了
    我留言和回复都放在gb表里的,不是分开的
    其中
      `reply` text,
      `retime` datetime default NULL,
    就是留言内容
      

  3.   

    就是说总共就这两张表除了还有张admin表外,就这两张表了
      

  4.   

    表二是attachment表,唯一表示符为aid.并有gb表唯一表示符id字段设成gid,id是gd表的id
    select * from gb where gid = id
    这是你想要的吗?
      

  5.   

    gb表中的存在的id 在attachment表中有相应的id吗?
      

  6.   

    不是,我是说在gb表中每一个id的记录,那在attachment表中有相应的id的记录吗?如果有的话,就用select * from gb,attachment where gb.id=attachment.id
      

  7.   

    你这样查询出来的不就是只有有附件的留言吗?没有附件的留言被你丢了啊,呵呵
    有的,插入的时候就有附件里的id和留言表里的id一样
      

  8.   

    我原来的查询语句
    $query = "Select * From gb Order By id Desc Limit " . $p->limit();
      

  9.   

    所以我问你:说在gb表中每一个id的记录,那在attachment表中有相应的id的记录吗?
      

  10.   

    试试这个看看,select * from gb,attachment where gb.id=attachment.id or (gb.id not in (select id from attachment))
      

  11.   

    呵呵MYSQL啦,现在应该还不支持吧?4.1.0支持不?