0

私の発言は正しいですか

$uid=1;
$pby=1;

$db->query("SELECT 
  CASE WHEN (c.uid!='$uid' and c.uid!='$pby')
    THEN
      ( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM 
   comments c join users u on c.uid=u.uid where c.msgid='$id' and 
   c.condition!='ga'   order by c.tstamp desc limit 10)
      )
 ELSE 
     ( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM 
      comments c join users u on c.uid=u.uid where c.msgid='$id'  
      order by c.tstamp desc limit 10)
      )
  END
  FROM comments c where c.msg_id='$id'") ;

これを試しましたが、空の結果がスローされます。何が悪いのかわからない

に更新

SELECT c.id、c.comment、c.uid、c.msgid、c.tstamp、u.fullname、u.img

  CASE WHEN (c.uid!='$uid' and c.uid!='$pby')
    THEN
      ( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM 
   comments c join users u on c.uid=u.uid where c.msgid='$id' and 
   c.condition!='ga'   order by c.tstamp desc limit 10)
      )
 ELSE 
     ( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM 
      comments c join users u on c.uid=u.uid where c.msgid='$id'  
      order by c.tstamp desc limit 10)
      )
  END
  FROM comments c join users u on c.uid=u.uid where c.msgid='$id'
4

1 に答える 1

0

選択するフィールドを指定し、クエリを次のように更新してください

$db->query("SELECT field1, field2
  CASE WHEN (c.uid!='$uid' and c.uid!='$pby')
    THEN
      ( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM 
   comments c join users u on c.uid=u.uid where c.msgid='$id' and 
   c.condition!='ga'   order by c.tstamp desc limit 10)
      )
 ELSE 
     ( SELECT c.id, c.comment, c.uid,c.msgid, c.tstamp, u.fullname, u.img FROM 
      comments c join users u on c.uid=u.uid where c.msgid='$id'  
      order by c.tstamp desc limit 10)
      )
  END
  FROM comments c where c.msg_id='$id'") ;
于 2013-11-06T07:17:06.263 に答える