猿创征文 第二季| #「笔耕不辍」--生命不息,写作不止#

84 阅读2分钟

欢迎大家参与投稿,分享#新学期,新FLAG#,投稿模板参考:

三表多表查询 左连接 太常见了 数据量如果过大导致查询速度不及预期(4、5秒之内)应当优化

三表多表查询
左连接
太常见了
数据量如果过大导致查询速度不及预期(4、5秒之内)应当优化

        select u.code,u.username, c.*
        from ad_call_record r
        left join lego_user.user u on r.user_id = u.id
        left join ad_callback_content c on r.ref_id = c.id


win10老是自动更新,彻底禁止自动更新

tieba.baidu.com/p/584853215…

Java两个数字字符串相加、两个数字字符串相乘(含%)

Java两个数字字符串相加

        //两个数字字符串相加
        String a = "75.2";
        String b = "77.5504000";
        BigDecimal c  = new BigDecimal(a);
        BigDecimal add = c.add(new BigDecimal(b));
        System.out.println(add.toString());
        //如果要保留两位小数
        System.out.println("=====" + add.setScale(2, BigDecimal.ROUND_HALF_UP));

两个数字字符串相乘(含%)

        //两个数字字符串相乘
        String a = "75.233";
        String b = "50";//50%
        BigDecimal c  = new BigDecimal(a);
        BigDecimal multiply = c.multiply(new BigDecimal(b)).divide(new BigDecimal(100));
        System.out.println(multiply.toString());
        //如果要保留两位小数
        System.out.println("=====" + multiply.setScale(2, BigDecimal.ROUND_HALF_UP));

首单付费用户总数sql

select DISTINCT lo.place_user_id AS '首单付费用户总数' from lego_order.order lo where DATE_FORMAT(lo.pay_time,'%Y-%m-%d') = '2021-12-01'
and (lo.pay_environment is null or lo.pay_environment != 'Sandbox')
        and lo.status = 2 and lo.place_user_type = 1
        and lo.pay_amount > 0 and lo.pay_type not in ('SSCM')
          and lo.platform = 'sscm'

 and lo.place_user_id not in (
select place_user_id from lego_order.order lo where DATE_FORMAT(lo.pay_time,'%Y-%m-%d') <'2021-12-01' and lo.platform = 'sscm'
and (lo.pay_environment is null or lo.pay_environment != 'Sandbox')
        and lo.status = 2 and lo.place_user_type = 1
        and lo.pay_amount > 0 and lo.pay_type not in ('SSCM')
            and lo.platform = 'sscm'

)#19


@GetMapping要使用@RequestParam(“userId“)/@PathVariable(name = “userCode“)

在这里插入图片描述
在这里插入图片描述
@GetMapping要使用@RequestParam(“userId”)/@PathVariable(name = “userCode”)
否则会报错

@PostMaping---->@RequestBody(对象)

常见数据库表后缀

copy结尾的是备份
flow结尾的是流水
rel结尾的是中间关联表
statistics结尾的是数据统计表
log结尾的是日志表
config结尾的是配置表

for循环遍历数组、集合(含代码)

1、泛型数组遍历出来,集合用ArrayList,遍历格式为(foreach):
for(类(将所有类型带过来) 循环变量名称(自定义一个e): 要被遍历的对象){
}2、for(元素的数据类型(int这些,包装类型integer也可) 变量自定义一个 : Collection集合or数组){

}
3、上代码:People.java

package com.equals;public class People {	
private Integer id;
	private String name;
		private String post;	
public Integer getId() {		
return id;	
}	

public void setId(Integer id) {	
	this.id = id;
		}	
public String getName() {	
	return name;	
	}	
public void setName(String name) {		
this.name = name;	
}	

public String getPost() {		
return post;	
}	
public void setPost(String post) {
		this.post = post;	
		}	
		public People(String name,String post){//
				this.id = id;		
				this.name = name;		
				this.post = post;	
				}
@Override	public String toString() {	
	return "People{" +				"id=" + id +				", name='" + name + '\'' +				", post='" + post + '\'' +				'}';	
}}

Test.java

package com.equals;import java.util.ArrayList;import java.util.Collection;public class test{	public static void main(String[] args) {	
	ArrayList<People> people = new ArrayList<>();		
people.add(new People("zhoonghau","php"));	
people.add(new People("zhoonghauzhognhuada","java1000"));		people.add(new People("zhoonghau3","php1111"));	
for (People e:people			 ) {	
					System.out.println("People{" +					"id=" + e.getId() +					", name='" + e.getName() + '\'' +					", post='" + e.getPost() + '\'' +					'}');		}	
						String[] arr = new String[]{"学生","职场人","管理员"};		Integer[] arr2 = new Integer[]{1,2,23};		
for (Integer w:arr2			 ) {	
	System.out.print(w+" ");	
									}	
System.out.println();	
Collection<String> collection = new ArrayList<>();		collection.add("jiyu "+"java");	
collection.add("xiaaohuadonghe");	
collection.add("zhongtongsida");		
for (String z:collection){	
		System.out.println(z);		
		}	}}

4、结果

People{id=null, name=‘zhoonghau’, post=‘php’}People{id=null, name=‘zhoonghauzhognhuada’, post=‘java1000’}People{id=null, name=‘zhoonghau3’, post=‘php1111’}1 2 23 jiyu javaxiaaohuadonghezhongtongsida

访问字符串

下面函数get_str2返回数组str的首地址,而从内存的堆区申请字符串的空间,可返回全部的

#include <stdio.h> char *get_str2(){ char str2[] = {"testing local pointer"}; return str2;

} char *get(){ char str; str = (char)malloc(100); if(!str) return NULL; strcpy(str,"testing local pointer"); return str; } int main(){ char *p; int i; char *m; int j; char a[] = {"testing local pointer"};

printf("第一种方法输出的是:\n"); p = get_str2();

for(i=0;*(p+i);i++)

putchar(*(p+i));

printf("\n");

m = get(); printf("第二种方法输出的是:\n"); for(j=0;(m+j);j++) putchar((m+j)); printf("\n");

}


文章知识点与官方知识档案匹配,可进一步学习相关知识

> 本文使用 [文章同步助手](https://juejin.cn/post/6940875049587097631) 同步