mysql

MySQL Crashing on SQL

£可爱£侵袭症+ 提交于 2021-02-10 06:10:49
问题 For the past 4 days MySQL keeps crashing on running scripts, like once / day this is the error log key_buffer_size=134217728 read_buffer_size=1048576 max_used_connections=39 max_threads=100 threads_connected=34 It is possible that mysqld could use up to key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 336508 K bytes of memory Hope that's ok; if not, decrease some variables in the equation. thd: 0x92025f38 Attempting backtrace. You can use the following information to find

How to Post data to database using Fetch API in React.js

懵懂的女人 提交于 2021-02-10 06:10:32
问题 I have recently learned how to set up a simple api in my express server using a localhost mySQL database I have running on a MAMP server. After I set that up I learned how to have React.js fetch that data and display it. Now I want to do the reverse and post data from a form I created in React.js. I would like to continue using the fetch API to post that data. You can view my code below. Below is my express server code for my api. app.get('/api/listitems', (req, res) => { connection.connect()

How to Post data to database using Fetch API in React.js

元气小坏坏 提交于 2021-02-10 06:09:21
问题 I have recently learned how to set up a simple api in my express server using a localhost mySQL database I have running on a MAMP server. After I set that up I learned how to have React.js fetch that data and display it. Now I want to do the reverse and post data from a form I created in React.js. I would like to continue using the fetch API to post that data. You can view my code below. Below is my express server code for my api. app.get('/api/listitems', (req, res) => { connection.connect()

MySQL Crashing on SQL

我只是一个虾纸丫 提交于 2021-02-10 06:08:26
问题 For the past 4 days MySQL keeps crashing on running scripts, like once / day this is the error log key_buffer_size=134217728 read_buffer_size=1048576 max_used_connections=39 max_threads=100 threads_connected=34 It is possible that mysqld could use up to key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 336508 K bytes of memory Hope that's ok; if not, decrease some variables in the equation. thd: 0x92025f38 Attempting backtrace. You can use the following information to find

Extracting ISO dates from a JSON Data type

佐手、 提交于 2021-02-10 06:03:42
问题 I am using MySQL json data type to store a JSON string. In the JSON string are two fields: entry_time , and entry_date . The values for these fields are stored in ISO 8609 format as follows: entry_date:2017-02-15T00:00:00.00Z entry_time:0000-00-00T04:35:51.29Z I am trying to create a virtual column from these two attributes. Since MySQL 5.7 has NO_ZERO_DATE set I cannot see a way to extract these values out as date and time columns. Here is what I have tried: alter table odh add entry_time

Make MySQL's ORDER BY dynamic in node.js

五迷三道 提交于 2021-02-10 05:56:48
问题 I want to make the ORDER BY dynamic in mysql query in node.js. But it's not working. I console.log the multiQuery variable and everything looks perfect but when ran it simply doesn't work. This is what I have: var order, multiQuery; if(req.query.o){ order = req.query.o; }else{ order = "views"; } multiQuery = 'SELECT COUNT(Category) AS Count FROM posts;'; //PROBLEM LIES HERE IN THE SECOND ONE multiQuery += 'SELECT ID, Title, Img_path, Category, Views FROM posts WHERE Category = ' + connection

MySQL 8 split string by comma and convert it into JSON ARRAY

走远了吗. 提交于 2021-02-10 05:54:33
问题 I have the following string: "a,b,c,d" and I want to convert it into a json array, something like this ["a","b","c","d"] is there any MySQL 8 function that can achieve this? 回答1: Try: SELECT CAST( CONCAT('["', REPLACE('a,b,c,d', ',', '","'), '"]') AS JSON ); See dbfiddle. 回答2: select json_array("a,b,c,d"); +-----------------------+ | json_array("a,b,c,d") | +-----------------------+ | ["a,b,c,d"] | +-----------------------+ 来源: https://stackoverflow.com/questions/56958056/mysql-8-split-string

MySQL 8 split string by comma and convert it into JSON ARRAY

瘦欲@ 提交于 2021-02-10 05:52:21
问题 I have the following string: "a,b,c,d" and I want to convert it into a json array, something like this ["a","b","c","d"] is there any MySQL 8 function that can achieve this? 回答1: Try: SELECT CAST( CONCAT('["', REPLACE('a,b,c,d', ',', '","'), '"]') AS JSON ); See dbfiddle. 回答2: select json_array("a,b,c,d"); +-----------------------+ | json_array("a,b,c,d") | +-----------------------+ | ["a,b,c,d"] | +-----------------------+ 来源: https://stackoverflow.com/questions/56958056/mysql-8-split-string

MySQL: Copy table to another table with an extra column

帅比萌擦擦* 提交于 2021-02-10 05:49:09
问题 I have two tables, tab1 and tab2. tab2 has all of the columns of tab1 but with an extra column for a timestamp. What I want to do is copy all of the rows from tab1 into tab2 and input the same time thae timestamp column for all rows that I insert. I can get and input the time fine, but I'm confused how to copy and insert data and fill in the last column with the timestamp for all of the rows that I inserted. So I want to do: Insert into tab2 select * from tab1 but I also want to add data for

Mutually exclusive values in SQL

限于喜欢 提交于 2021-02-10 05:40:57
问题 I have a query which selects products from a table. A product can have multiple prices (think of various prices) and a default price. Naturally, this is a one-to-many relation. I need to select the products which have a given price, or the default price - which means mutual exclusion. I know this can be done through separate queries and a WHERE (not) IN clauses or a union statement, but I'm convinced a more optimal way must be possible. My query currently looks like this: SELECT products.*,