我有以下错误:
[You have an error in your SQL syntax; check the manual that corresponds
to your MariaDB server version for the right syntax to use near \'\' at line 4]
SELECT COUNT(*) FROM wp_postmeta AS a, wp_postmeta AS b
WHERE a.post_id = b.post_id AND (a.meta_key = \'customer_email\'
AND a.meta_value LIKE \'%[email protected]%\') AND (b.meta_key = \'usage_count\' AND b.meta_value = \'0\'
但是,它在PHPMYADMIN正常工作
我不知道出了什么问题。
我的代码是
$rowcount = $wpdb->get_var("SELECT COUNT(*)
FROM $wpdb->postmeta AS a, $wpdb->postmeta AS b WHERE a.post_id = b.post_id AND (a.meta_key = \'customer_email\'
AND a.meta_value LIKE \'%[email protected]%\') AND (b.meta_key = \'usage_count\' AND b.meta_value = \'0\'");
echo $rowcount;
如何修复此问题?