doutandusegang2961 2018-04-12 20:08 采纳率: 0%
浏览 333
已采纳

laravel 5.5 group by不起作用

I'm trying to get some data but I just get this error

SQLSTATE[42000]: Syntax error or access violation: 1055 'ms_mascotas.ms_razas.id' isn't in GROUP BY (SQL: select ms_razas.id, ms_razas.nombre, ms_mascotas.raza_id, ms_mascotas.id from ms_mascotas inner join ms_razas on ms_razas.id = ms_mascotas.raza_id where ms_razas.tipo_animal_id = 1 group by ms_mascotas.raza_id)"

my query is this

$data=Mascota::select("ms_razas.id","ms_razas.nombre","ms_mascotas.raza_id","ms_mascotas.id")
       ->join("ms_razas","ms_razas.id","=","ms_mascotas.raza_id")
       ->where("ms_razas.tipo_animal_id",$id)
       ->groupBy("ms_mascotas.raza_id")
       ->get();

I've been reading about this error and it is related with the strict mode in the database file, strict is set to false by default, what should I do?

  • 写回答

2条回答 默认 最新

  • duanliaolan6178 2018-04-13 04:49
    关注

    go to your config\database.php and change the setting the database that you use

    'strict' => false
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度