我有这个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);
我还有一个变量$ query,它包含一个多字查询(比如“hello world”),我想用这个搜索我的数据库。我已经尝试了正确的事情(我认为),但它一直返回0。
答案 0 :(得分: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