![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
项目碎片——sql
Dkui
夯实根基,蓄积勃发。
展开
-
navicat for oracle 误操作恢复语句
navicat for oracle 误操作恢复语句原创 2021-12-15 18:17:32 · 929 阅读 · 0 评论 -
查询某个字段的时间区间数据
select COUNT(*) from to_tools where deleted = '0' and new_type = ${type} and datepart(yyyy,online_time) = ${year1} and datepart(mm,online_time) >= ${startinTime} and datepart(mm,online_time) <= ${deadl原创 2021-06-12 08:50:30 · 258 阅读 · 0 评论 -
多字段去重并返回所有数据
SELECT a.* from nd_tracking_file a , (SELECT max(id) as id from nd_tracking_file group by bl,container_number ORDER BY id ASC)b where a.id = b.id去重字段 bl,container_number原创 2021-05-07 16:48:01 · 241 阅读 · 0 评论 -
sqlserver单表备份语句
select * into to_FltPsgInfo_20210115 from to_FltPsgInfoto_FltPsgInfo_20210115 新的表名原创 2021-01-15 16:30:56 · 5486 阅读 · 0 评论 -
将id字段中包含19的换成20 replace函数
update st_cla_copy set id=replace(id,'19','20') replace 这个函数SQL中的替换函数replace()使用语法REPLACE ( string_expression , string_pattern , string_replacement )参数string_expression 要搜索的字符串表达式。string_expression 可以是字符或二进制数据类型。string_pattern 是要查找的子字符串。string_pa原创 2020-09-17 11:43:06 · 164 阅读 · 0 评论 -
必须掌握的30种SQL语句优化
必须掌握的30种SQL语句优化1.’对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。2.应尽量避免在 where 子句中使用!=或<>操作符,否则将引擎放弃使用索引而进行全表扫描。3.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如:select id from t where num is null可以在num上设置默认值0,确保表中num列没有null值,然后这样查询:原创 2020-08-25 14:40:35 · 106 阅读 · 0 评论 -
多字段拼接
需求:照片字段 = 学号 + “.jpg”语句UPDATEst_studentSET st_photo = CONCAT(student_id,'.jpg')WHERE student_id = id原创 2020-07-06 14:57:56 · 138 阅读 · 0 评论 -
调接口
1,后端写好接口2.前端 api中定义//图书申请const tuEdit = (params)=>postAction("/bo/boBook/tuEdit",params);export {tuEdit}2.去写好的以页面引入 import { tuEdit } from '@/api/api' console.log("表单提交数据",formData) tuEdit(formData).then((res)=>{原创 2020-06-25 13:48:22 · 393 阅读 · 0 评论 -
多表条件查询
@AutoLog(value = "根据成果等条件查询教师") @ApiOperation(value = "根据成果等条件查询教师",notes="根据成果等条件查询教师") @GetMapping(value = "/selectTeacher") public Result<?> selectTeacher(String finished, String totalPaper, ...原创 2020-06-15 09:39:54 · 483 阅读 · 0 评论 -
只获取时间里的年
select DATE_FORMAT(birth_date,'%Y') from amployeesbirth_date---时间字段amployees---表名%Y---年原创 2020-06-10 21:24:13 · 182 阅读 · 0 评论 -
limit 1000000 加载很慢的话,你是怎么解决的呢
方案一:如果id是连续的,可以这样,返回上次查询的最大记录(偏移量),再往下limitselect id,name from employee where id>1000000 limit 10.复制代码方案二:在业务允许的情况下限制页数:建议跟业务讨论,有没有必要查这么后的分页啦。因为绝大多数用户都不会往后翻太多页。方案三:order by + 索引(id为索引)select id,name from employee order by id limit 1000000,10.原创 2020-06-05 16:22:43 · 1662 阅读 · 0 评论 -
查询出荣誉表的类型大于2的所有老师id
语句SELECT DISTINCT a.teacher_id,a.typeFROM sta_sci_paper aJOIN ( SELECT type FROM sta_sci_paper GROUP BY type HAVING COUNT(type) >4AND type='1' ) bON a.type = b.type;原创 2020-06-04 09:27:44 · 154 阅读 · 0 评论 -
根据当前用户查询一条记录
这里主要是通过创建时间和用户id来筛选SELECT *FROM sta_papers_statisticalWHERE teacher_id = '1248103043254280194'ORDER BY create_time DESCLIMIT 0, 1;原创 2020-05-18 16:25:12 · 309 阅读 · 0 评论 -
新增,更新a表的数据等于b表数据——sql
//2019 更新成 2019级update st_student set field_two=CONCAT(field_two,'级')更新年级UPDATE st_student,sys_dict_itemSET field_two = item_value WHERE st_student.field_two = sys_dict_item.item_text...原创 2019-12-23 15:21:22 · 811 阅读 · 0 评论 -
模糊更新将a表的数据等于b表数据——sql
update st_student as a ,(select * from st_areas where level=1)as b set a.province=b.areaname where b.areaname like CONCAT(a.province,'%')原创 2019-12-23 19:54:13 · 319 阅读 · 0 评论 -
删掉学生表里没有班级表里得班级数据——sql
delete from st_student where st_class not in (select id from st_class )原创 2019-12-23 21:29:57 · 848 阅读 · 0 评论 -
更新数据表为空的值——sql
UPDATE st_student SET nationality='57'WHERE nationality is nullis null原创 2019-12-24 10:39:11 · 1085 阅读 · 0 评论 -
不等于格式——sql
<![CDATA[ punish <> '1' ]]>原创 2020-01-02 16:17:44 · 179 阅读 · 0 评论 -
写sql语句将数字字典数转换成汉字——sql
Controller /** * 通过学号获得学生荣誉列表 * 通过学号获得学生荣誉列表 * getStudentHonor */ @AutoLog(value = "通过学号获得学生荣誉列表") @ApiOperation(value="通过学号获得学生荣誉列表", notes="通过学号获得学生荣誉列表") @GetMap...原创 2020-01-14 15:21:04 · 2342 阅读 · 0 评论 -
年月日获得当中的年月和年并统计和里面的数据——sql
select SUM(account) count ,CONCAT( DATE_FORMAT(billing_time, '%Y'), '-', DATE_FORMAT(billing_time, '%m') ) days,CONCAT( DATE_FORMAT(billing_time, '%Y') ...原创 2020-01-17 15:51:06 · 288 阅读 · 0 评论 -
sql拼接字符——sql
SELECT project_id as projectId, account_name as accountName, account as account, billing_time as billingTime, spend_type as spendTypeFROM zj_bookkeepingWHEREdeleted='0'AND ((convert(billi...原创 2020-01-18 11:53:30 · 157 阅读 · 0 评论 -
查询某时间范围内的值——sql
SELECT project_id as project, SUM(account) count, spend_type as spendType FROM zj_bookkeeping WHERE deleted='0' <![CDATA[ AND ...原创 2020-01-18 11:55:05 · 850 阅读 · 0 评论 -
sql——查重,去重
查重SELECT count(1), professionFROM st_professionGROUP BY professionHAVING count(1) > 1表需要删除重复的记录(重复记录保留1条)select distinct * into #Tmp from TB_MAT_BasicData1drop table TB_MAT_BasicData1...原创 2020-05-07 17:39:01 · 394 阅读 · 0 评论