Before I begin I know that these questions exist: Get an R dataframe with merged values from multiple MySQL tables and Best approach to combine multiple MySQL tables in R. But I can't use them for my problem.
I have a list of schemas (let's say 80 schemas) in a MySQL database with a specific ProductID such as shj637, jsfh748, hasd548 etc. I've added a specific table with a specific name in all those schemas as ProductINFO (so all schemas have this table). In which they all have the same column names (like ID, name, product group, etc) but different values in rows.
What I want to do is to make a loop or a function, that would load and union all ProductINFO tables from different ProductID schemas and make one data frame with all those information that contain their specific ProductIDs (as a column).
So for example if: schema A with ProductID shj637 and schema B with ProductID kly457 and 80 more! they would all have one table called ProductINFO. I want to produce:
ProductID | ID | group | otherstuff |
---|---|---|---|
shj637 | 1 | Q2 | ghafdj... |
shj637 | 2 | Q4 | jhsdf... |
shj637 | 3 | Q1 | jhfdl... |
kly457 | 1 | Q2 | jshfd... |
kly457 | 2 | Q4 | uiepc... |
kly457 | 3 | Q1 | qapfn.. |
.. for all 80 ProductID schemas |
This is the table structure:
CREATE TABLE `productinfo` (
`ID` int(11) DEFAULT NULL,
`Question` text,
`Product Answer` double DEFAULT NULL,
`Product Code/Script (If Required)` test,
`Product Score/Mark` double DEFAULT NULL,
`Feedback` text,
`ProductID` text,
`database ID` text)
ENGINE=MyISAM DEFAULT CHARSET=latin1
Thank you in advance!