mysql

Select on value change

北城余情 提交于 2021-02-10 18:20:30
问题 I have a table that looks like this in a MySQL database: CREATE TABLE IF NOT EXISTS Example(Batch_Num int, Time DATETIME); INSERT INTO Example VALUES (1,'2020-12-04 05:06:12'), (1,'2020-12-04 05:06:13'), (1,'2020-12-04 05:06:14'), (2,'2020-12-04 05:06:20'), (2,'2020-12-04 05:07:12'), (2,'2020-12-04 05:07:20'), (1,'2020-12-04 05:07:25'), (1,'2020-12-04 05:07:35'), (3,'2020-12-04 05:07:35'); I would like to select all lines where the Batch_Num is different from the previous value including the

SQL Query Join in CodeIgniter

丶灬走出姿态 提交于 2021-02-10 18:18:55
问题 I have this query and I need it to be in the CodeIgniter way (query builder). I know how to use the standard query builder class functions, but I have difficulties to find a way how to build a LEFT JOIN with an inner SELECT clause using the CI Query Builder Class. SELECT * FROM sma_products p LEFT JOIN (SELECT product_id, Count(*) FROM sma_sale_items GROUP BY product_id) s ON p.id = s.product_id ORDER BY ` Count(*) ` DESC 回答1: The difficulty to create this SQL with CI query builder lies in

MySQL one to many relationship: GROUP_CONCAT or JOIN or both?

不羁的心 提交于 2021-02-10 18:11:33
问题 I need help with a MySQL query. I have three tables: `product_category` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL, PRIMARY KEY (`id`) ); `order_products` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL, `qty` int(11) NOT NULL, `unit_price` decimal(11,2) NOT NULL, `category` int(11) NOT NULL, `order_id` int (11) NOT NULL, PRIMARY KEY (`id`) ); `orders` ( `id` int(11) NOT NULL auto_increment, `date` varchar(255) NOT NULL, PRIMARY KEY (`id`) ); I

centos 6.8 安装percona pmm(监控神器)

馋奶兔 提交于 2021-02-10 17:55:35
centos 6.8 安装percona pmm(监控神器) sql1101 关注 0人评论 15005人阅读 2018-12-07 13:47:59 背景: 完善的监控对系统的稳定性,运维,调优,故障定位都起着非常重要的作用,监控在整个运维体系中有着举着轻重的作用,所以有一个完善的监控平台非常重要,下面就要介绍一个percona的Pmm监控平台,非常强大,强大非常 一,安装pmm server yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm yum install docker-io 1,查看docker 版本: 2,启动docker service docker start 3,创建Pmm 容器 docker create \ -v /opt/prometheus/data \ -v /opt/consul-data \ -v /var/lib/mysql \ -v /var/lib/grafana \ --name pmm-data \ percona/pmm-server:1.1.1 /bin/true 4,运行这个容器 docker run -d \ -p 80:80 \ --volumes-from pmm-data \ --name pmm

Error: Access denied for user ''@'localhost' (using password: NO)

只谈情不闲聊 提交于 2021-02-10 17:47:01
问题 I'm trying out db migrations with MySQL and Knex. When I run the command knex migrate:latest , I get ER_ACCESS_DENIED_ERROR: Access denied for user ''@'localhost' (using password: NO) I've tried adding a password on the codebase (to '123' and 'NO'), though what confuses me most is that even as I have user: "root" in my database file, the error gives an empty string as the user... I share what I imagine are the pertinent files: // mysql_db.js const knex = require('knex')({ client: 'mysql',

how to like/unlike with button using toggleclass

孤街浪徒 提交于 2021-02-10 17:36:19
问题 this is my like button... HTML code <div class="btn"> <div class="boxcoracao"> <span class="coracao" id = "<?php echo $postid?>" name = "like">br>   Love</span> </div> </div>    Jquery inside HTML <script> $(".btn ").click(function(){ $('.boxcoracao .coracao', this).toggleClass("ativo"); }); </script> it works when i click and unclick the button the button changes but what my problem is how can i use this function to save data to my database. sample when 1st click the button it will like..

Windows系统下使用Docker的踩坑记录

家住魔仙堡 提交于 2021-02-10 17:00:27
  在实际Windows系统使用Docker的过程中,碰到很多坑,记录问题、原因、解决办法如下。 1. 使用MySQL镜像报错 问题描述 使用MySQL镜像会报错,报错内容为: [ERROR] InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. 原因: 使用的文件系統不支持aio 解决办法: 在docker-compose.yml文件中,添加命令: command: "--innodb_use_native_aio=0" ,如下所示: mysql: environment: MYSQL_DATABASE: test MYSQL_PASSWORD: root MYSQL_ROOT_PASSWORD: root TZ: Asia/Shanghai image: mysql:latest command: "--innodb_use_native_aio=0" ports: - 3306:3306 volumes: - ./data/mysql/data:/var/lib/mysql 参考网址: https://stackoverflow.com/questions/48239668/fails-to-initialize-mysql-database-on-windows-10 2. 启动Docker时报错

How do I update thousands of records into MySQL DB in milliseconds

一世执手 提交于 2021-02-10 16:55:29
问题 I want to update about 10K records into MySQL DB in less than a second. I have written below code which takes about 6-8 seconds to update a list of records into DB. public void updateResultList(List<?> list) { String user = "root"; String pass = "root"; String jdbcUrl = "jdbc:mysql://12.1.1.1/db_1?useSSL=false"; String driver = "com.mysql.jdbc.Driver"; PreparedStatement pstm = null; try { Class.forName(driver); Connection myConn = DriverManager.getConnection(jdbcUrl, user, pass); myConn

聊聊中间件开发

邮差的信 提交于 2021-02-10 16:49:44
最近频繁地在跟实习生候选人打交道,每次新接触一个候选人,都要花上一定的时间去介绍我们团队,候选人问的最多的一个问题就是「中间件部门一般是干嘛的?」,恰好我之前也接触过一些想从事中间件开发的小伙伴,问过我「现在转行做中间件开发还来得及吗?」诸如此类的问题,索性就写一篇文章,聊聊我个人这些年做中间件开发的感受吧。 什么是中间件开发? 我大四实习时,在一个 20 多人的软件开发团队第一次接触了中间件,当时项目的架构师引入了微博开源的 RPC 框架 Motan,借助于这个框架,我们迅速构建起了一个基于微服务架构的内部电商系统。接着在项目中,由于业务需求,我们又引入了 ActiveMQ...在这个阶段,我已经在使用中间件了,但似乎没有接触到中间件开发,更多的是使用层面上的接触。 我毕业后的第一份工作,公司有几百号研发,当时的 leader 看我对中间件比较感兴趣,有意把我分配在了基础架构团队,我第一次真正意义上成为了一名”中间件研发“,平时主要的工作,是基于开源的 Kong 和 Dubbo,进行一些内部的改造,以提供给业务团队更好地使用。这个阶段,做的事还是比较杂的,业务团队对某些中间件有定制化的需求,都需要去了解这个中间件,熟悉源码。这段时间,也是我成长最快的一个时期,我是在这个期间学会了 Docker、Neo4j、Kong 等以前从来没接触过的技术,并且更加深入地了解 Dubbo 这类

Not able to connect Laravel application on App Engine to Cloud SQL database

元气小坏坏 提交于 2021-02-10 16:44:33
问题 I have a Laravel application running on Google App Engine and I want to connect it to the Google Cloud SQL database I have. I have tried many solutions none of them fixed the problem. Everytime it does a request to the database, it throws SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from sessions where id = CQZwtQFAm5RCYcP4ZSqf5mtxTnebGUigQQKVluJa limit 1) . I do have the sessions table, and I also get this error while trying to log in but with the users table then. I've