In need of an advanced SQL Query

I have loaded all my Databases into MySQL. I need to query 14 databases simultaneously. I have two two columns that are consistent across all 14, orderID and cartorderID.
The orderID is the Primary and cartorderId is the Foreign key. There are about 30 to 40 columns per database with other data that I need to ignore. The data extracted needs to be joined into a single row. I may remove the duplicates later with another tool so I’m not concerned with duplicates. At this point the final output table can be called anything because I will be renaming it later in the script.

Any help offered is greatly appreciated. Thanks in advance.

sounds like a join might be what you want

i’m going to assume that when you said “databases” you actually meant “tables”

now, what’s supposed to happen if one of the 14 tables doesn’t have a row for a particular orderID?

having the same orderID number in 14 different tables does sound a little weird, though

why do you have 14 different tables?

Yes, I need to use the JOIN command for those two rows. I did mean “databases”. I pulled 14 databases from various hosts all into my local server. I want to query all of them with one SQL command. The two tables are Orders and Cart. I will be pulling data from orderID which is a row in the Order table and cartorderID which is a row in the Cart table.

and all these hosts all have the same orderID? like, say you had orderID number 937 in one database, it would have to exist in all the other 13 databases before you wanted to see any of the data for 937?

i hope you don’t mind if i say that i still don’t believe that you actually want JOIN

and by the way, when you said orderID is a row, you meant column


yes, when I say orderID I mean column. It’s just that all the data from the two columns will be merged into one row. So the primary key and foreign key is what ties the two tables together. The rest of all the data in each table is nearly identical.