草庐IT

first_column

全部标签

Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown column 'xxx' in 'where clause'

在使用Ruoyi管理系统中出现这个问题Errorqueryingdatabase.Cause:java.sql.SQLSyntaxErrorException:Unknowncolumn'xxx_time'in'whereclause'因为对应报错的SQL中没有该字段,前端也没有传入该字段,而且这个问题是偶发的,所以一直也没查到原因。今天心血来潮追溯了下源码隐约发现了问题所在。#首先声明:#1.先确认是不是确实是字段写错了#2.这个锅Ruoyi不背,PageHelper也不背,问题肯定就是出在业务代码里。#解决方式:#1.确保PageHelper的startPage方法之后直接执行doSele

Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown column 'xxx' in 'where clause'

在使用Ruoyi管理系统中出现这个问题Errorqueryingdatabase.Cause:java.sql.SQLSyntaxErrorException:Unknowncolumn'xxx_time'in'whereclause'因为对应报错的SQL中没有该字段,前端也没有传入该字段,而且这个问题是偶发的,所以一直也没查到原因。今天心血来潮追溯了下源码隐约发现了问题所在。#首先声明:#1.先确认是不是确实是字段写错了#2.这个锅Ruoyi不背,PageHelper也不背,问题肯定就是出在业务代码里。#解决方式:#1.确保PageHelper的startPage方法之后直接执行doSele

leetcode 34. Find First and Last Position of Element in Sorted Array 在排序数组中查找元素的第一个和最后一个位置(中等)

一、题目大意标签:查找https://leetcode.cn/problems/find-first-and-last-position-of-element-in-sorted-array给定一个按照升序排列的整数数组nums,和一个目标值target。找出给定目标值在数组中的开始位置和结束位置。如果数组中不存在目标值target,返回 [-1,-1]。进阶:你可以设计并实现时间复杂度为 O(logn) 的算法解决此问题吗?示例1:输入:nums=[5,7,7,8,8,10],target=8输出:[3,4]示例 2:输入:nums=[5,7,7,8,8,10],target=6输出:[-1

leetcode 34. Find First and Last Position of Element in Sorted Array 在排序数组中查找元素的第一个和最后一个位置(中等)

一、题目大意标签:查找https://leetcode.cn/problems/find-first-and-last-position-of-element-in-sorted-array给定一个按照升序排列的整数数组nums,和一个目标值target。找出给定目标值在数组中的开始位置和结束位置。如果数组中不存在目标值target,返回 [-1,-1]。进阶:你可以设计并实现时间复杂度为 O(logn) 的算法解决此问题吗?示例1:输入:nums=[5,7,7,8,8,10],target=8输出:[3,4]示例 2:输入:nums=[5,7,7,8,8,10],target=6输出:[-1

洛谷P3654 First Step题解

题目传送门这是一道暴力枚举。  大致题意:R行C列的棋盘要放下长度为K的线段,“#”表示无法放置,问有多少种放置方法。直接贴代码:#includeusingnamespacestd;intmain(){stringstr;//读取字符串intr,c,k,a[101][101],cnt=0;//数组a用来存储棋盘cin>>r>>c>>k;//r表示行,c表示列,k表示线段长度for(inti=1;i){cin>>str;//输入for(intj=1;j){if(str[j-1]=='.')//将棋盘字符转为数值表示是否可以放置a[i][j]=0;//0表示可以放置elsea[i][j]=1;//

洛谷P3654 First Step题解

题目传送门这是一道暴力枚举。  大致题意:R行C列的棋盘要放下长度为K的线段,“#”表示无法放置,问有多少种放置方法。直接贴代码:#includeusingnamespacestd;intmain(){stringstr;//读取字符串intr,c,k,a[101][101],cnt=0;//数组a用来存储棋盘cin>>r>>c>>k;//r表示行,c表示列,k表示线段长度for(inti=1;i){cin>>str;//输入for(intj=1;j){if(str[j-1]=='.')//将棋盘字符转为数值表示是否可以放置a[i][j]=0;//0表示可以放置elsea[i][j]=1;//

Golang error : "scannable dest type ptr with >1 columns (3) in result"

项目中的dao层,我们用来查询数据库,获取想要数据。有时我们会需要查询数据给结构体赋值,并返回一个结构体指针,如下//结构体字段已与数据库对应funcGetCommunity(idint)(community*model.CommunityDetail,errerror){ sql:=`selectcommunity_id,community_name,introductionfromcommunitywherecommunity_id=?` err=db.Get(&community,sql,id) iferr!=nil{ return } return}这样的代码看似没有问题,但其实并不

Golang error : "scannable dest type ptr with >1 columns (3) in result"

项目中的dao层,我们用来查询数据库,获取想要数据。有时我们会需要查询数据给结构体赋值,并返回一个结构体指针,如下//结构体字段已与数据库对应funcGetCommunity(idint)(community*model.CommunityDetail,errerror){ sql:=`selectcommunity_id,community_name,introductionfromcommunitywherecommunity_id=?` err=db.Get(&community,sql,id) iferr!=nil{ return } return}这样的代码看似没有问题,但其实并不

mysql使用group by查询报错SELECT list is not in GROUP BY clause and contains nonaggregated column...原因及解决方案

在项目中需要用到groupby进行聚合计算,在计算的同时也要查出一些其他字段来返回给前端。于是就有了这个错误的出现。先简单复现我所写的sql,其实sql非常简单。selectchannel_nameaschannelName,brand_nameasbrandName,sum(actual_value)asactualValue,sum(actual_value_ty)asactualValueTy,sum(actual_value_ly)asactualValueLy,sum(target_value)astargetValuefrombu_channel_base_performanceg

mysql使用group by查询报错SELECT list is not in GROUP BY clause and contains nonaggregated column...原因及解决方案

在项目中需要用到groupby进行聚合计算,在计算的同时也要查出一些其他字段来返回给前端。于是就有了这个错误的出现。先简单复现我所写的sql,其实sql非常简单。selectchannel_nameaschannelName,brand_nameasbrandName,sum(actual_value)asactualValue,sum(actual_value_ty)asactualValueTy,sum(actual_value_ly)asactualValueLy,sum(target_value)astargetValuefrombu_channel_base_performanceg