在阅读了许多类似的线程后,我在这里发帖,但这并不能解决我的问题,所以我需要 MySQL 专家来帮助我确定这个查询有什么问题:
查询如下所示:
SELECT DISTINCT(p.ID), p.*, pm.*, t.*, tt.*, tr.*
FROM wp_posts p, wp_postmeta pm, wp_terms as t, wp_term_taxonomy as tt, wp_term_relationships as tr
'WHERE p.ID = pm.post_id
AND t.term_id = tt.term_id
AND tt.taxonomy = wpsc_product_category
AND tt.term_taxonomy_id = tr.term_taxonomy_id
AND tr.object_id = p.ID
AND p.post_type = wpsc-product
AND pm.meta_key != _wpsc_price
AND (p.post_title LIKE '%'\"some string to search\"'%'
OR p.post_content LIKE '%'\"some string to search\"'%'
OR pm.meta_value = '\"some string to search\"'
OR t.name LIKE '%'\"some string to search\"'%')
GROUP BY p.ID ORDER By p.ID '
我不知道查询格式有什么问题得到以下错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''WHERE p.ID = pm.post_id AND t.term_id = tt.term_id AND tt.taxonomy = wpsc_produ' at line 1
在我的查询中,我需要整合字符串,而我现在更改为 PDO 为时已晚。我该如何解决这个错误?
PS:我在本地服务器上运行,所以 php info 向我显示了有关 MySQL 服务器的信息,我猜它是版本:
Client API version 5.5.29