我正在尝试比较mysql中的url,但查询返回与任何url匹配的结果。
这是我的查询。
SELECT
a.comment_ID,
a.comment_post_ID,
a.comment_content,
a.comment_date_gmt,
a.comment_author_url,
b.post_title, b.ID
FROM
`wp_comments` a,
`wp_posts` b
WHERE
a.comment_post_ID = b.ID
AND
('a.comment_author_email' = '$email'
OR
'a.comment_author_url' = '$url')
AND a.comment_approved = 1
GROUP BY a.comment_ID
ORDER BY a.comment_ID DESC
谢谢!
编辑:full query
答案 0 :(得分:2)
在您的查询中,请确保将所有'
(单引号)字符替换为`
(反引号)字符。
答案 1 :(得分:0)
提示:
'
INNER JOIN
可以让事情变得更容易尝试这个
$qry = " SELECT { watever} FROM `wp_comments` a,
INNER JOIN `wp_posts` b ON `a`.`comment_post_ID` = `b`.`ID`
WHERE
`a`.`comment_author_email` = '".$email."'
OR `a`.`comment_author_url` ='". $url."'
GROUP BY `a`.`comment_ID`
ORDER BY `a`.`comment_ID` DESC ";