-2

私はこのSQLとPHPを持っています:

$articles = returndata("
     SELECT 
         (SELECT COUNT(*) from blog_posts) as totalcount,
         (SELECT COUNT(*) from comments where assetid = d.assetid) as replies,
         c.name as categoryname,
         d.category as categoryid,
         d.assetid, 
         d.title,
         d.postdate,
         d.articlecontent
     FROM blog_categories c 
         INNER JOIN 
         blog_posts d 
     GROUP BY d.assetid 
     ORDER BY postdate DESC 
         LIMIT " . (($page - 1) * $size) . ", " . $size
, $database);

また、複数の単語のクエリ( "hello world"など)を含む変数$ queryがあり、これを使用してデータベースを検索したいと思います。私は正しいことを試しましたが(私は思う)、それは0を返し続けます。

4

1 に答える 1

1

これを試して ::

SELECT 
(SELECT COUNT(*) from blog_posts) as totalcount, 
(SELECT COUNT(*) from comments where assetid = d.assetid) as replies, 
c.name as categoryname, 
d.category as categoryid, 
d.assetid, 
d.title, 
d.postdate, 
d.articlecontent 
FROM blog_categories c 
INNER JOIN blog_posts d on // join condition
// THE WHERE CLAUSE SHOULD BE HERE LIKE column like '%sample word%'


GROUP BY d.assetid ORDER BY postdate DESC LIMIT 
于 2012-12-04T18:47:55.623 に答える