【Mysql】select * from test group by id引发的错误

昨天同事写了一段sql没报错(开发环境),我本地报错了,sql如下

select * from test group by id

一般情况下,select查询的字段,如果用group by 分组查询的话,必须把select后面的字段全部分组,解决这问题需要我们自己配置来解决

查询配置,本地环境和开发环境的确实是不一样
在这里插入图片描述
修改配置
找到mysql目录下的my.cnf,如果是windows的话,则是my.ini
在[mysqld]下删除**ONLY_FULL_GROUP_BY **
在这里插入图片描述
重启mysql服务就生效了。

查询下
SELECT @@sql_mode;
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Thomas Erl有关SOA的又一巨著。 Product Description “This book could be described as an encyclopedia of service design–Erl leaves nothing to chance. Indispensable.” –Steve Birkel, Chief IT Technical Architect, Intel Corp. “An absolute pleasure to read…the best SOA book I’ve read. A book I would recommend to all of my colleagues; it provides much insight to the topics often overlooked by most books in this genre…the visuals were fantastic.” –Brandon Bohling, SOA Architecture and Strategy, Intel Corporation “This book is a milestone in SOA literature. For the first time we are provided with a practical guide on defining service characteristics and service design principles for SOA from a vendor-agnostic viewpoint. It’s a great reference for SOA discovery, adoptions, and implementation projects.” –Canyang Kevin Liu, Principal Enterprise Architect, SAP Americas, Inc. “I liked this book. It contains extremely important material for those who need to design services.” –Farzin Yashar, IBM SOA Advanced Technologies “This book does a great job laying out benefits, key ideas and design principles behind successfully adopting service-oriented computing. At the same time, the book openly addresses challenges, risks and trade-offs that are in the way of adopting SOA in the real-world today. It moves away from ivory-tower views of service orientation, but still lays out a strong vision for SOA and outlines the changes necessary to realize the full potential.” –Christoph Schittko, Senior Architect, Microsoft
以下是JavaWeb实现简单的增删查改功能的步骤: 1.创建数据库表和实体类 首先需要创建对应的数据库表和实体类,例如创建一个名为adoption的表,包含id、name、age等字段,并创建一个Adoption实体类,包含对应的属性和get/set方法。 2.创建Mapper接口和SQL映射文件 创建一个AdoMapper接口,包含增删查改的方法,例如: ```java public interface AdoMapper { //查询所有记录 List<Adoption> findAll(); //根据id查询记录 Adoption findById(int id); //添加记录 void add(Adoption adoption); //更新记录 void update(Adoption adoption); //根据id删除记录 void deleteById(int id); } ``` 然后创建对应的SQL映射文件,例如: ```xml <!-- 查询所有记录 --> <select id="findAll" resultType="com.example.demo.entity.Adoption"> select * from adoption </select> <!-- 根据id查询记录 --> <select id="findById" parameterType="int" resultType="com.example.demo.entity.Adoption"> select * from adoption where id=#{id} </select> <!-- 添加记录 --> <insert id="add" parameterType="com.example.demo.entity.Adoption"> insert into adoption(name, age) values(#{name}, #{age}) </insert> <!-- 更新记录 --> <update id="update" parameterType="com.example.demo.entity.Adoption"> update adoption set name=#{name}, age=#{age} where id=#{id} </update> <!-- 根据id删除记录 --> <delete id="deleteById" parameterType="int"> delete from adoption where id=#{id} </delete> ``` 3.创建Service层和Controller层 创建一个AdoService接口和AdoServiceImpl实现类,包含对应的增删查改方法,例如: ```java public interface AdoService { List<Adoption> findAll(); Adoption findById(int id); void add(Adoption adoption); void update(Adoption adoption); void deleteById(int id); } @Service public class AdoServiceImpl implements AdoService { @Autowired private AdoMapper adoMapper; @Override public List<Adoption> findAll() { return adoMapper.findAll(); } @Override public Adoption findById(int id) { return adoMapper.findById(id); } @Override public void add(Adoption adoption) { adoMapper.add(adoption); } @Override public void update(Adoption adoption) { adoMapper.update(adoption); } @Override public void deleteById(int id) { adoMapper.deleteById(id); } } ``` 然后创建一个AdoController类,处理对应的请求,例如: ```java @Controller @RequestMapping("/ado") public class AdoController { @Autowired private AdoService adoService; //查询所有记录 @GetMapping("/findAll") public String findAll(Model model) { List<Adoption> adoptions = adoService.findAll(); model.addAttribute("adoptions", adoptions); return "ado_list"; } //根据id查询记录 @GetMapping("/findById/{id}") public String findById(@PathVariable("id") int id, Model model) { Adoption adoption = adoService.findById(id); model.addAttribute("adoption", adoption); return "ado_info"; } //跳转到添加记录页面 @GetMapping("/toAdd") public String toAdd() { return "ado_add"; } //添加记录 @PostMapping("/add") public String add(Adoption adoption) { adoService.add(adoption); return "redirect:/ado/findAll"; } //跳转到更新记录页面 @GetMapping("/toUpdate/{id}") public String toUpdate(@PathVariable("id") int id, Model model) { Adoption adoption = adoService.findById(id); model.addAttribute("adoption", adoption); return "ado_update"; } //更新记录 @PostMapping("/update") public String update(Adoption adoption) { adoService.update(adoption); return "redirect:/ado/findAll"; } //根据id删除记录 @GetMapping("/deleteById/{id}") public String deleteById(@PathVariable("id") int id) { adoService.deleteById(id); return "redirect:/ado/findAll"; } } ``` 4.创建对应的页面 最后需要创建对应的页面,例如ado_list.html、ado_info.html、ado_add.html、ado_update.html等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值