查询在MySQL Workbench中运行,但不在php中的mysql_query()中运行

时间:2011-07-20 12:33:05

标签: php mysql mysql-workbench

select t1.* 
from bbs_product as t1, bbs_category as t2 
where 
(((t1.product_name_de like '%13"%') or 
(t1.sku_number like '%13"%') or 
(t1.description like '%13"%')) and 
((t1.product_name_de like '%Laptoptasche%') or 
(t1.sku_number like '%Laptoptasche%') or 
(t1.description like '%Laptoptasche%')) and 
((t1.product_name_de like '%im%') or 
(t1.sku_number like '%im%') or 
(t1.description like '%im%')) and 
((t1.product_name_de like '%Buchdesign%') or 
(t1.sku_number like '%Buchdesign%') or 
(t1.description like '%Buchdesign%'))) and 
(t1.category_id=t2.id and t2.status=1) and 
t1.status=1 and 
t1.discontinued='no' and 
t1.is_secret='n'

1 个答案:

答案 0 :(得分:4)

t1.sku_number like '%13"%') or 
(t1.description like '%13"%')) and 

您的查询文字中有双引号。

确保它们在PHP字符串中正确转义,该字符串是mysql_query的参数。