SQL query to find the most repeated 2 value across all columns - mysql

Hi I have a table with all numeric values inserted in column 1, column 2, column 3.....
I know how to find the most repeated two values from one column but our goal is to find the most repeated two from all tables. Could you help provide any quicker thoughts?

Related

Mysql - Inserting multiple values into empty column of existing table without specifying all "where" conditions

I have a table in MySQL and I have append a new column to it with emtpy fields.
Now I am wondering if there is a possibility to append multiple rows to only this specific column without specifying the "where" condition for each row because there are many entries I wanted to so
I have something like this
INSERT INTO table.name
(`column.name`) VALUES
(2,
3,
1,
2,
0);
So that for the first row all values for each column stay the same but the value 2 will be appended to that corresponding empty column, for the 2nd row the value 3 will be attached and so on.
So I wanted to add for ALL rows a corresponding value in this new column. So the first value is for the first row, the second value of this new column for the 2nd row and so on
Thank you in advance!

MySQL error 1136, why can I not add these entries to my table

Code
Error
I don't know why I keep getting an error
Thank you in advance
INSERT syntax allows inserting multiple rows, but each row needs to be in its own tuple:
insert into shoppinglistTest(itemdescription, quantity, dateadded)
values
('Bananas',20,'0000-00-00'),
('apples',10,'0000-00-00'),
('grapes',20,'0000-00-00'),
('gatorade',10,'0000-00-00'),
('steak',10,'0000-00-00'),
('milk',2,'0000-00-00'),
('eggs',4,'0000-00-00');
The syntax you tried to use used a single tuple of 21 values for a column list of 3 columns. The number of columns in your column list must be the same as the number of values in each tuple in the VALUES clause. But you can make a list of many tuples.

How do I insert outputted data into a column on mysql?

I have a column with numbers and I need to find the difference of that from 10 and insert all the values in parallel in a different column. Can anyone tell me how to get this data into a new column under the name "10-data" and update the same table?

Insert into table from another with different columns count (MySQL)

Question, why this dose not work?
create table one (a int(1) default 1, b int(2));
create table two (b int(1));
insert into one select * from two;
error:
Column count doesn't match value count at row 1
a know it, a can count, but why, philosophically?
database knows, what the name of inserting column from table two is b, knows that the column a in table one has a default value equal 1..
so, what problem of executing this query?
And general - How can i do this differently, not manual, without information of a columns and their count, if this way is impossible?
I know this:
table two always have all the same columns, that the table one have. But table one have another columns too, that have a some default values.
Is there some way to do that? insert all data from two in one, and fill the remaining columns by some default or other values!
Need help!
Thank you very match!
When you run:
insert into one
select * from two;
The SQL engine automatically puts in the columns that are implied.
For the insert, this is the list of columns in declaration order.
For the *, this is the list of columns in declaration order.
There is no "matching" of columns by names, only lists of columns in each table.
So, the query is really:
insert into one(a, b)
select b from two;
That looks like an error to me.
Moral of the story? Write that code that you intend. Always include columns lists, particularly for insert statements. So write:
insert into one(b)
select b from two;

Microsoft Access Duplicate Output Destination workaround

I have a column containing 123 unique Raw Material Names and another column called OutgoingRawMaterial, the idea being that we can look at the table and see that 270 units of Ingredient A left the company etc.
I wanted to create an update query which would update the related OutgoingRawMaterial with the figure from the query 'qrySumManufacturingRawMaterials' which contains the figures I want. The Update Query works fine for individual records, as below:
Field: OutgoingRawMaterial
Table: tblRawMaterialsManufactured
Update to: [tblSumManufacturingRawMaterials Query].[Expr1]
Criteria: [RawMaterial] Like "Raw Material 1*"
The problem is that I want to do the same for all 123 records and don't know how to do this, short of creating 123 queries and running them all from a macro or VBA. I was also going to create a single query with all 123 Raw Materials, using a different 'LIKE' to isolate them, but get the "Duplicate Output Destination 'tblRawMaterialsManufactured.OutgoingRawMaterial'" I can confirm that I only have one column named 'OutgoingRawMaterial'.
UPDATE:
The answer below is how you would normally solve this. The way you're trying to do it by having 2 columns with a bunch of records and a 3rd column with the sum is actually considered a bad design because your third column is not related to the first 2 columns. You'll have tell me more to understand how that third column will work - does it contain 123 sum (aggregate) values while the first 2 columns contains say hundreds of individual values?
The easiest approach would be to delete everything and recreate the table. For example, let's say that 'qrySumManufacturingRawMaterials' outputs something like this:
Raw1 | 1
Raw2 | 2
...
And OutgoingRawMaterial has the same format then you can just do a INSERT INTO SELECT:
DELETE FROM OutgoingRawMaterial;
INSERT INTO OutgoingRawMaterial SELECT 'qrySumManufacturingRawMaterials'
There are many variations on this - for example if the query outputs different column names you can change the query to INSERT INTO OutgoingRawMaterial (Col1, Col2, ...) so if you need more help please update the question.