New answers tagged

0

I did the same - but moved from docker hosted on Windows 10 to a docker on Debian 10.9 - both having the /var/lib/mysql docker-mapped to a host directory. If I move from docker on Windows to docker on another Windows machine there is no error. I therefore suspected the different ways of handling case sensitivity on Windows and Linux. Inspecting the files in /...


1

You want something like this (works for >= 5.5 at least): SELECT i_name, i_price, COUNT(i_qty) AS "Number sold", SUM(i_price) AS "Total revenue" FROM item GROUP BY i_name, i_price ORDER BY i_price; Result: i_name i_price Number sold Total revenue Tea 10 3 30 Coffee 10 2 ...


1

You need to be looking at GROUP BY and aggregate functions. See https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html for mysql's documentation. In this case it looks like: You want to be grouping by Item Name, you can just use the field directly in SELECT then as it is part of the grouping. For Qty use the counting aggregate (COUNT(*)). For ...


2

As you insert, add a big number (big enough to be past the existing ids) to the id column for the incoming rows. Plan A: Load into a temp table, then INSERT .. SELECT id+100000, ... FROM temp. Plan B: LOAD DATA INFILE ... ..., @id = id, ... SET id = @id + 100000 Caveat: You must not be inserting into the table from other sources during ...


3

Another solution is to use LOAD DATA [LOCAL] INFILE, but override the columns list so the auto-increment value is inserted into a dummy variable: Here's a demo: I have a text file I call c.csv: 1 foo bar 2 baz bam 3 blee bloo I want to insert into mytable, but id's 1,2,3 are already occupied. I want the csv data to be inserted, ...


2

Here is a quick and dirty way to accomplish the task: Create a new table on the old server using the same schema minus the primary key Copy the records from the source table to the dummy table Export the data using mysqldump or something in phpMyAdmin Change the INSERT INTO {table} strings in the export to have the correct table name Import the data to the ...


Top 50 recent answers are included