Mysql 一个sql查询已经在主机上运行良好,但在WAMP上不起作用
Mysql 一个sql查询已经在主机上运行良好,但在WAMP上不起作用,mysql,sql,Mysql,Sql,我有一个sql查询,它已经在主机上运行得很好了,但是在WAMP上没有,我得到了sql错误1064,请帮助
我有一个sql查询,它已经在主机上运行得很好了,但是在WAMP上没有,我得到了sql错误1064,请帮助<谢谢
$query = 'SELECT p.products_id, p.products_image, p.products_tax_class_id, p.products_ordered, IF (s.status, s.specials_new_products_price, NULL) AS specials_new_products_price, p.products_price, pd.products_name, p.products_model';
if ( defined('FEATURED_MODUL_SPECIALS_ONLY') AND FEATURED_MODUL_SPECIALS_ONLY == 'true' ) {
$query .= 'FROM ' . TABLE_SPECIALS . ' s LEFT JOIN ' . TABLE_PRODUCTS . ' p ON s.products_id = p.products_id ';
} else {
$query .= 'FROM ' . TABLE_PRODUCTS . ' p LEFT JOIN ' . TABLE_SPECIALS . ' s ON p.products_id = s.products_id ';
}
if ($current_page != FILENAME_DEFAULT) {
$query .= 'LEFT JOIN ' . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id AND pd.language_id = '" . $languages_id . "'
LEFT JOIN " . TABLE_FEATURED . " f ON p.products_id = f.products_id
WHERE p.products_status = '1' AND f.status = '1' order by rand($mtm) DESC limit " . FEATURED_MODUL_MAX_DISPLAY;
}else{
$query .= 'LEFT JOIN ' . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id AND pd.language_id = '" . $languages_id . "'
LEFT JOIN " . TABLE_FEATURED . " f ON p.products_id = f.products_id
WHERE p.products_status = '1' AND f.status = '1' order by rand($mtm) DESC limit " . FEATURED_MODUL_MAX_DISPLAY_FIRST_PAGE;
}
我在WAMP服务器上出错:1064-您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以了解在第1行中使用接近“p LEFT JOIN specials s ON p.products\u id=s.products\u id LEFT JOIN products\u descr”的正确语法 选择p.products\u id、p.products\u image、p.products\u tax\u class\u id、p.products\u ordered,如果(s.status、s.specials\u new\u products\u price、NULL)作为specials\u new\u products\u price、p.products\u price、pd.products\u name,p.products\u model from products p LEFT JOIN specials ON p.products\u id=s.products\u id LEFT JOIN products\u description pd ON p.products\u id=pd.products\u id和pd.language\u id='1'LEFT JOIN特色f ON p.products\u id=f.products\u id其中p.products\u status='1'和f.status='1'订单按兰德(12852)描述限制12
[TEP STOP]我不知道这个查询是如何编写的。第一个字符串是:
'SELECT p.products_id, p.products_image, p.products_tax_class_id, p.products_ordered, IF (s.status, s.specials_new_products_price, NULL) AS specials_new_products_price, p.products_price, pd.products_name, p.products_model'
第二个是:
'FROM ' . TABLE_SPECIALS . ' s LEFT JOIN ' . TABLE_PRODUCTS . ' p ON s.products_id = p.products_id '
或
在这两种情况下,select
列表如下所示:
'p.process_modelFROM '
我怀疑这是表中的一列。我怀疑这个查询也缺少一个来自子句的
将空格放回select
行的末尾,查询就可以了
您得到的特定错误发生在编译器的第一个过程中。它正在查找关键字left join
,但它们不在from
子句中。可能您的本地计算机上有不同版本的MySQL服务器?在生成的语句中,您的from
前面没有空格。尝试在它之前添加一个空格。
'p.process_modelFROM '