douxiong0668 2016-09-18 17:18 采纳率: 100%
浏览 150

使用mysql严格模式的SQL请求

I have an error with a sql request with mysql 7.0 Do you have an idea on this request to change?

[18-Sep-2016 13:08:17 America/New_York] PHP Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.p.products_model' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by in /home/www/clicshopping_test_ui/boutique/includes/ClicShopping/OM/DbStatement.php on line 97

My request about this error

$QuppliersProducts1 = $OSCOM_Db->prepare('
        select  p.products_model,s.suppliers_id, 
                sum(op.products_quantity) as sum_qty,    
                s.suppliers_name,op.products_name, 
                opa.products_options, opa.products_options_values   
        from :table_orders_products  op
            left join :table_products p ON op.products_id = p.products_id
            left join :table_suppliers s on p.suppliers_id = s.suppliers_id
            left join :table_orders  o ON op.orders_id = o.orders_id
            left join :table_orders_products_attributes opa ON op.orders_products_id = opa.orders_products_id
        where o.date_purchased between :date_purchased_start  
            and :date_purchased_end
            and s.suppliers_id = :suppliers_id
            and o.orders_status = :orders_status 
            and s.suppliers_id = :suppliers_id
        group by op.products_name, opa.products_options, 
                  opa.products_options_values
        order by p.products_model, op.products_name');

  $QuppliersProducts1->bindInt(':date_purchased_start', (int)$_GET['bDS'] );
  $QuppliersProducts1->bindInt(':date_purchased_end', (int)$_GET['bED'] );
  $QuppliersProducts1->bindInt(':suppliers_id', (int)$_GET['bID'] );
  $QuppliersProducts1->bindInt(':orders_status', (int)$_GET['bOS'] );

  $QuppliersProducts1->execute();
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 java在应用程序里获取不到扬声器设备
    • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
    • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
    • ¥15 Attention is all you need 的代码运行
    • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
    • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
    • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
    • ¥80 部署运行web自动化项目
    • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
    • ¥30 VMware 云桌面水印如何添加