mysql

PHP/MySql search array with array

混江龙づ霸主 提交于 2021-02-08 02:58:08
问题 I'm building a WordPress website. With a MySql Query I load all companies from my database that have a specific brand: $results = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE meta_key = 'brand'")` brand is an array so I search for a specific value in array: $brand = $_GET['brand']; $brandNeedle = $brand; if(in_array($brandNeedle, $brand[0])) Now, my client asked to list all users that are connected to all those companies that are selected. So I need to create a new query.

Java中RunTime类介绍

有些话、适合烂在心里 提交于 2021-02-08 02:56:43
Runtime 类代表着Java程序的运行时环境,每个Java程序都有一个Runtime实例,该类会被自动创建,我们可以通过 Runtime.getRuntime() 方法来获取当前程序的Runtime实例。 获取当前Jvm的内存信息 /* * 获取当前jvm的内存信息,返回的值是 字节为单位 * */ public static void getFreeMemory() { // 获取可用内存 long value = Runtime.getRuntime().freeMemory(); System.out.println( "可用内存为:"+value/1024/1024+"mb" ); // 获取jvm的总数量,该值会不断的变化 long totalMemory = Runtime.getRuntime().totalMemory(); System.out.println( "全部内存为:"+totalMemory/1024/1024+"mb" ); // 获取jvm 可以最大使用的内存数量,如果没有被限制 返回 Long.MAX_VALUE; long maxMemory = Runtime.getRuntime().maxMemory(); System.out.println( "可用最大内存为:"+maxMemory/1024/1024+"mb" ); }

Combine two word from a MySQL database at random

强颜欢笑 提交于 2021-02-08 02:56:27
问题 I have a database with nouns and adjectives for example: id | type | word ----------------------- 1 | noun | apple 2 | noun | ball 3 | adj | clammy 4 | noun | keyboard 5 | adj | bloody ect... I want to create one query what will grab 10 random adjectives and 10 random nouns and put them together. Having trouble doing it, is this possible? Thank you! 回答1: You can get 10 random elements per type with queries like this: select word from YOUR_TABLE where type = 'noun' order by rand() limit 10;

爱奇艺现场面试总结

帅比萌擦擦* 提交于 2021-02-08 02:54:59
一面: java内存模型:问面试官是jmm还是jvm,说是jvm,说了说分区 堆内存:说了堆内存划分和理由,各种内存的分配流程,各类回收算法。 项目:略 mysql锁存在哪里的:想不起来了。。。 mysql乐观锁悲观锁:乐观锁说了mvcc,悲观锁说了行锁表锁 mysql mvcc实现:说了下那两列blablabla,又说了下除了mvcc外还用了啥来保证可重复读 aqs:自己看过源码,就着lock类说,包括tryaquire,addwaiter,公平锁非公平锁实现区别 jdk1.7 1.8区别:部分容器类改进(如hashmap,concurrenthashmap),stream,lambda stream怎么实现的:底层用的类似fork join fork join怎么实现的:把人物分开,然两两后合并结果 写个归并排序:之前快排和堆排都练过,就归并。。。。没练,没憋出来 sql写行转列:。。尴尬,也写不出 springboot了解么:实验项目用过,着重说了下默认配置和springloud的基础 springcloud说下,画画图:主要说了eruka,ribbon,hystrix,fegin,config,bus,zuul 二面: 项目:略 后台开发高并发的理解:提高服务器配置,分布,服务管理,负载均衡,一致性处理,缓存,数据库分库分表,高可用,页面静态化都说了说,各说了下大致怎么做的

mysql主从只同步部分库或表

会有一股神秘感。 提交于 2021-02-08 02:41:40
同步部分数据有两个思路,1.master只发送需要的;2.slave只接收想要的。 master端: binlog-do-db 二进制日志记录的数据库(多数据库用逗号,隔开) binlog-ignore-db 二进制日志中忽略数据库 (多数据库用逗号,隔开) 举例说明: 1) binlog-do-db=YYY 需要同步的数据库,不在内的不同步。(不添加这行表示同步所有) 这里主库只同步test1,test2库。 2)binlog-ignore-db = mysql 这是不记录binlog,来达到从库不同步mysql库,以确保各自权限 binlog-ignore-db = performance_schema binlog-ignore-db = information_schema 这里向从库同步时忽略test1,test2库 slave端 replicate-do-db 设定需要复制的数据库(多数据库使用逗号,隔开) replicate-ignore-db 设定需要忽略的复制数据库 (多数据库使用逗号,隔开) replicate-do-table 设定需要复制的表 replicate-ignore-table 设定需要忽略的复制表 replicate-wild-do-table 同replication-do-table功能一样,但是可以通配符 replicate-wild

MySQL: Pivot + Counting

☆樱花仙子☆ 提交于 2021-02-08 01:57:45
问题 I need help with a SQL that will convert this table: =================== | Id | FK | Status| =================== | 1 | A | 100 | | 2 | A | 101 | | 3 | B | 100 | | 4 | B | 101 | | 5 | C | 100 | | 6 | C | 101 | | 7 | A | 102 | | 8 | A | 102 | | 9 | B | 102 | | 10 | B | 102 | =================== to this: ========================================== | FK | Count 100 | Count 101 | Count 102 | ========================================== | A | 1 | 1 | 2 | | B | 1 | 1 | 2 | | C | 1 | 1 | 0 | ===========

Determine if two names are close to each other

六眼飞鱼酱① 提交于 2021-02-07 23:13:19
问题 I'm making a system for my school where we can check if a student is black-listed, at parties and other events. It's easy for me to check if a student is black-listed, since I can just look the student up in my database and see if he/she is black-listed. Here is where it gets difficult though. At our parties, each student can invite one person. In theory a student who is black-listed, can be invited by another student and bypass the system. I cannot check the guest table for students black

我被炒鱿鱼了!

六眼飞鱼酱① 提交于 2021-02-07 22:49:31
凌晨2点,正在做梦,突然接到了技术总监的电话:明天来公司收拾收拾,办理离职! 说实话当时我头脑一片空白,直接懵了。 第二天到公司,才知道我写的一段代码, 昨天一天让公司损失了100多万 ,被定性为重大事故,导致了我直接被炒鱿鱼,而我的一些领导也受到了牵连,让我十分愧疚。 这个业务应该很多人都会遇到,所以拿出来分享一下,避免大家踩坑。 我们公司是做投资理财的,用户可以充值、投资、提现,充值这块是我做的,使用第三方支付进行充值,过程如下: step1:用户网站中输入充值金额 step2:后端创建充值订单入库,此时订单是待支付状态 step3:跳转到第三方支付页面,输入银行卡,然后确认支付 step4:第三方支付通过我方提供的回调接口异步将充值结果告知我方 问题出在了step4,逻辑如下: //返回通知处理结果,true:处理成功;false:处理失败,第三方会继续重试 public boolean rechargeNotice (第三方支付充值结果) { try { //第三方充值结果中包含了我方的订单id,从db中获取充值订单信息 OrderModel order = this .getOrderById(订单id); //@1 //判断订单状态是否是待支付状态 if (订单状态 == 待支付状态){ //@2 //将订单状态置为充值成功 order.status(充值成功);

Does MySQL create an extra index for primary key or uses the data itself as an “index”

微笑、不失礼 提交于 2021-02-07 22:47:43
问题 Cant find a explicit answer of that. I know that when you create a primary key, MySQL orders the data according to that primary key, question is, does it actually create another index, or uses the actual data as an index since it should be ordered by the primary key? EDIT: if I have a table with has index A and index B and no primary key, I have the data + index A + index B. If I change the table to have columns of index A as the primary key, I will only have data (which is also used as an

MYSQL报Fatal error encountered during command execution.错误的解决方法

核能气质少年 提交于 2021-02-07 21:34:58
MYSQL报Fatal error encountered during command execution.错误的解决方法 参考文章: (1)MYSQL报Fatal error encountered during command execution.错误的解决方法 (2)https://www.cnblogs.com/qiywtc/p/4813167.html 备忘一下。 来源: oschina 链接: https://my.oschina.net/u/3797416/blog/4733251