mysql


Uncaught exception 'PDOException' with message 'SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value

荒凉一梦 提交于 2020-01-23 02:33:30
问题 This is the error I am getting. PDOException: Uncaught exception 'PDOException' with message 'SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF0\x9F\x98\xB3' for column 'string' at row 1' I know the problem here. The column table is using utf8 . The utf8 encoding cannot store 4 byte characters so it errors. A way to get around this could be to use utf8mb4 instead. My question instead is about the error message. We are using MariaDB. Why does it say "Invalid datetime

SELECT query in WHERE clause of UPDATE query [duplicate]

放肆的年华 提交于 2020-01-23 02:06:13
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Mysql error 1093 - Can’t specify target table for update in FROM clause I am getting an error when putting SELECT query in WHERE clause of UPDATE query. my Query is like this : UPDATE `subschedulesseats` m SET m.studentid='1' WHERE m.`seatid`= ( SELECT h.`seatid` FROM `subschedulesseats` h WHERE h.`sessiontime`='02:30~04:00' ORDER BY h.`seatid` ASC LIMIT 2,1 ) AND Error will be shown is like this : "You can't

What are your favorite Ruby on Rails books and why? [closed]

别说谁变了你拦得住时间么 提交于 2020-01-23 01:40:14
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I'm looking to pick up a few books on RoR to help teach myself how to build a scalable RoR app. I have read the RailsSpace book, and

HQL how to join three table

 ̄綄美尐妖づ 提交于 2020-01-23 01:33:06
问题 I Have this classes: @Entity public class Category { private Long Id; private String name; private String description; private List<Product> products; } @Entity public class Inventory { private Long id; private Product product; private int quantity; } @Entity public class Product { private Long productId; private String name; } I want to get the Inventory given the id in the category. i'm trying to use this return session.createQuery("select i from Inventory i, Category c join c.Products p

if else query in mysql

自古美人都是妖i 提交于 2020-01-23 01:29:10
问题 i need an example of nested if-else condition in mysql query 回答1: You could also use case statements for if-else conditions SELECT (CASE field1 WHEN 'A' THEN 'value is A' WHEN 'B' THEN 'value is B' ELSE 'value is neither A or B' END) FROM your_table; or SELECT (CASE WHEN (field1 IS NULL) THEN 'value is NULL' WHEN (field1 = 1) THEN 'value is 1' ELSE 'value is neither NULL or 1' END) FROM your_table; 回答2: You mean the IF( expr , expr , expr ) function as defined here? An example would be:

mariadb password and unix_socket authentication for root

a 夏天 提交于 2020-01-23 01:10:53
问题 I've a root User on the MariaDB on Ubuntu 16.04. As default the root user is authenticated by the unix_socket authentication plugin. I can switch the authentication method to password method by setting update mysql.user set plugin='' where user='root'; This works fine. But ... Is there a possibility to authenticate the root user by unix_socket (by root shell) or by password (when it is connected by localhost:3306)? 回答1: A reliable and straightforward way would be to create another super-user

Spring boot 2 upgrade - spring boot data jpa saveAll() very slow

落爺英雄遲暮 提交于 2020-01-23 01:04:09
问题 I use mysql with hibernate and spring boot data jpa (spring-boot-starter-data-jpa and mysql-connector-java). Recently I upgraded my spring boot project from 1.5 to 2.0. The API of the spring data CrudRepository to save an iterable has changed form save() to saveAll(). I made the changes in the code and it works but it is very slow: insert 10 items -> 2 times slower (49ms -> 95ms) insert 100 items -> 6 times slower (132ms -> 840ms) insert 1000 items -> 10 times slower (792ms -> 8028ms) insert

MySQLNonTransientConnectionException Could not create connection to database server. Caused by: java.lang.NullPointerException

北战南征 提交于 2020-01-22 23:22:28
问题 I have a local MySQL Community server (8.0.11) running on a local host at 127.0.0.1:3306 . (I created a database and registered a user for it). I can use the following terminal query to access the database: ./mysql -u testuser -p and the I am able to get access to the server. I am using Spring and JDBC to do the same thing using the following code: private final String URL= "jdbc:mysql://127.0.0.1:3306/db_example?useSSL=false"; private final String DB_USERNAME = "testuser"; private final

Select most occurring value in MySQL

爷,独闯天下 提交于 2020-01-22 23:07:39
问题 I'm looking for a way to select the most occurring value, e.g. the person who posted most for each thread; SELECT MOST_OCCURRING(user_id) FROM thread_posts GROUP BY thread_id Is there a good way to do this? 回答1: If you want a count on a per thread basis, I think you can use a nested query; grouping by thread first and then by user: SELECT thread_id AS tid, (SELECT user_id FROM thread_posts WHERE thread_id = tid GROUP BY user_id ORDER BY COUNT(*) DESC LIMIT 0,1) AS topUser FROM thread_posts

Select most occurring value in MySQL

柔情痞子 提交于 2020-01-22 23:07:04
问题 I'm looking for a way to select the most occurring value, e.g. the person who posted most for each thread; SELECT MOST_OCCURRING(user_id) FROM thread_posts GROUP BY thread_id Is there a good way to do this? 回答1: If you want a count on a per thread basis, I think you can use a nested query; grouping by thread first and then by user: SELECT thread_id AS tid, (SELECT user_id FROM thread_posts WHERE thread_id = tid GROUP BY user_id ORDER BY COUNT(*) DESC LIMIT 0,1) AS topUser FROM thread_posts

工具导航Map