我安装了新的Ubuntu,我的代码遇到了MySQL问题.
( ! ) Warning: PDOStatement::execute(): SQLSTATE[HY000]: General error: 3065
Expression #2 of ORDER BY clause is not in SELECT list, references column 'clicshopping_test_ui.p.products_date_added' which is not in SELECT list; this is incompatible with DISTINCT
in /home/www//boutique/includes/OM/DbStatement.php on line 97s
Run Code Online (Sandbox Code Playgroud)
似乎MySQL 5.7不允许这样的请求:
select .... distinct with order by rand(), p.products_date_added DESC
Run Code Online (Sandbox Code Playgroud)
如果我使用它,它的工作原理:
select distinct .... with order by rand(),
Run Code Online (Sandbox Code Playgroud)
如何解决这种情况?
我在PHP中的SQL请求
$Qproduct = $OSCOM_PDO->prepare('select distinct p.products_id,
p.products_price
from :table_products p left join :table_specials s on p.products_id = s.products_id
where products_status …
Run Code Online (Sandbox Code Playgroud) 我的查询有问题,mysql抛出以下错误:
Run Code Online (Sandbox Code Playgroud)#1055 - Expression #66 of SELECT list is not in GROUP BY clause and contains nonaggregated column 's.status' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
查询是:
select p.*,
pd.*,
m.*,
IF(s.status, s.specials_new_products_price, null) as specials_new_products_price,
IF(s.status, s.specials_new_products_price, p.products_price) as final_price
FROM products p
LEFT JOIN specials s ON p.products_id = s.products_id
LEFT JOIN manufacturers m using(manufacturers_id) ,
products_description pd,
categories c,
products_to_categories p2c
WHERE p.products_view = 1
AND p.products_status = …
Run Code Online (Sandbox Code Playgroud) 我在 MYSQL 5.7 上收到此请求的错误。如何解决这个错误?
#1055 - SELECT 列表的表达式 #3 不在 GROUP BY 子句中,并且包含非聚合列“test.c.customers_group_id”,该列在功能上不依赖于 GROUP BY 子句中的列;这与 sql_mode=only_full_group_by 不兼容
select SQL_CALC_FOUND_ROWS c.customers_firstname,
c.customers_lastname,
c.customers_group_id,
sum(op.products_quantity * op.final_price) as ordersum
from customers c,
orders_products op,
orders o
where c.customers_id = o.customers_id
and o.orders_id = op.orders_id
group by c.customers_firstname,
c.customers_lastname
order by ordersum DESC
Run Code Online (Sandbox Code Playgroud)